Commit 496cffb8 authored by Panagiotis Skarvelis's avatar Panagiotis Skarvelis
Browse files

gen audit on init

parent 6d89e780
export declare const getIdentity: () => Promise<any>;
import { AuditRecord } from '@digigov-oss/gsis-audit-record-db';
export declare const getIdentity: (afm: string, auditInit?: AuditRecord, auditStoragePath?: string) => Promise<any>;
export default getIdentity;
import soap from './soap';
import { generateAuditRecord } from '@digigov-oss/gsis-audit-record-db';
import config from '../config.json'; //TODO replace with args
export const getIdentity = async () => {
export const getIdentity = async (afm, auditInit = {}, auditStoragePath = '/tmp') => {
const auditRecord = generateAuditRecord(auditInit, auditStoragePath);
if (!auditRecord)
throw new Error('Audit record is not initialized');
try {
const s = new soap(config.test.wsdl, config.test.user, config.test.pass);
const Identity = await s.getIdentity();
const s = new soap(config.test.wsdl, config.test.user, config.test.pass, auditRecord);
const Identity = await s.getIdentity("019285930");
return Identity;
}
catch (error) {
......
import soap from 'soap';
import { AuditRecord } from '@digigov-oss/gsis-audit-record-db';
declare class Soap {
private _client;
private _wsdl;
private _username;
private _password;
constructor(wsdl: string, username: string, password: string);
private _auditRecord;
constructor(wsdl: string, username: string, password: string, auditRecord: AuditRecord);
init(): Promise<soap.Client>;
getIdentity(): Promise<any>;
getIdentity(vat: string): Promise<any>;
}
export default Soap;
import soap from 'soap';
import { generateAuditRecord } from '@digigov-oss/gsis-audit-record-db';
class Soap {
_client;
_wsdl;
_username;
_password;
constructor(wsdl, username, password) {
_auditRecord;
constructor(wsdl, username, password, auditRecord) {
this._wsdl = wsdl;
this._username = username;
this._password = password;
this._auditRecord = auditRecord;
}
async init() {
try {
......@@ -24,7 +25,7 @@ class Soap {
throw e;
}
}
async getIdentity() {
async getIdentity(vat) {
try {
const client = await this.init();
var options = {
......@@ -33,11 +34,11 @@ class Soap {
};
var wsSecurity = new soap.WSSecurity(this._username, this._password, options);
client.setSecurity(wsSecurity);
const auditRecord = await generateAuditRecord({});
const auditRecord = this._auditRecord;
const args = {
auditRecord: auditRecord,
getNncIdentityInputRecord: {
afm: "019285930"
afm: vat
}
};
const result = await client.getNncIdentityAsync(args);
......
import soap from './soap';
import config from '../config.json'; //TODO replace with args
export const getIdentity = async () => {
import {generateAuditRecord,AuditRecord} from '@digigov-oss/gsis-audit-record-db';
try {
const s = new soap(config.test.wsdl, config.test.user, config.test.pass);
const Identity = await s.getIdentity();
import config from '../config.json'; //TODO replace with args
export const getIdentity = async (afm:string, auditInit: AuditRecord={}, auditStoragePath: string='/tmp') => {
const auditRecord = generateAuditRecord(auditInit, auditStoragePath);
if (!auditRecord) throw new Error('Audit record is not initialized');
try {
const s = new soap(config.test.wsdl, config.test.user, config.test.pass, auditRecord);
const Identity = await s.getIdentity("019285930");
return Identity;
} catch (error) {
throw(error);
......
import soap from 'soap';
import {generateAuditRecord} from '@digigov-oss/gsis-audit-record-db';
import {AuditRecord} from '@digigov-oss/gsis-audit-record-db';
class Soap {
private _client: any;
private _wsdl: string;
private _username: string;
private _password: string;
private _auditRecord: AuditRecord;
constructor(wsdl: string, username: string, password: string) {
constructor(wsdl: string, username: string, password: string,auditRecord: AuditRecord) {
this._wsdl = wsdl;
this._username = username;
this._password = password;
this._auditRecord = auditRecord;
}
public async init() {
......@@ -28,7 +31,7 @@ class Soap {
}
}
public async getIdentity() {
public async getIdentity(vat:string) {
try {
const client = await this.init();
var options = {
......@@ -37,11 +40,11 @@ class Soap {
};
var wsSecurity = new soap.WSSecurity(this._username, this._password, options)
client.setSecurity(wsSecurity);
const auditRecord = await generateAuditRecord({});
const auditRecord = this._auditRecord;
const args = {
auditRecord: auditRecord,
getNncIdentityInputRecord:{
afm:"019285930"
afm:vat
}
}
const result = await client.getNncIdentityAsync(args);
......
import getIdentity from '../src/index';
const test = async () => {
try {
const Identity = await getIdentity();
const Identity = await getIdentity("052704062");
console.log("getNncIdentityOutputRecord=", Identity);
} catch (error) {
console.log(error);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment