-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetLibrayVersion.js
More file actions
111 lines (96 loc) · 3.12 KB
/
GetLibrayVersion.js
File metadata and controls
111 lines (96 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
"use strict";
var soap = require('strong-soap').soap;
const util = require('util');
/**
* [userLogin your wallet login]
* @type {String}
*/
var userLogin = "myUserAsInKyc";
/**
* [userPassword
* @type {String}
*/
var userPassword = "myPasswordAsInKyc";
/**
* callerId is a preshared key that identifies the API consumer as a valid and known entity
* @type {String}
*/
var callerId = "00000000-0000-0000-0000-000000000000";
/**
* [url the path tothe WSDL file of the API]
* @type {String}
* @Remark For local wsdl you can use, url = './wsdls/wpyWDSL.xml' - or any other filesystem location
*/
var url = './WSDL/WinstantPayWebService.xml';
/**
* [options this object can be used to further configure the soap client]
* see https://github.com/strongloop/strong-soap for details on the options
* @type {Object}
*/
var options = {};
/**
* [wsSecurity Implements WS-Security. UsernameToken and PasswordText/PasswordDigest is supported.]
* @type {soap}
*/
var wsSecurity = new soap.WSSecurity(userLogin, userPassword, options);
/**
* errHandlke - Simply prints the error message to the console
* @param {String}
* @return {void}
*/
var errHandler = function(err) {
console.log(err);
}
/**
* GetLibraryVersion - the functions calls the GetLibraryVersion endPoint of the GPWeb Webservice API
*
* @param {soapClient} client - The soapClient
* @return {String} librayVersion - The currect Version
*/
function GetLibraryVersion(client) {
/**
* [args Contain the arguments for the soap module call]
* @type {Object}
*/
let args = {
};
/**
* @param {Function} - resolve is call when the function succeeds
* @param {Function} - reject is called when the method called technically fails -
* sementical errors will be returned on the result buffer, which is a parsd JSON object,
* and are not handled here
* @return {void}
*/
return new Promise(function(resolve, reject) {
var method = client['GPWebService']['BasicHttpsBinding_IGPWebService1']['GetLibraryVersion'];
method(args, function(err, result, envelope, soapHeader) {
if (err) {
reject(err);
} else {
var gpWebResult = result;
var librayVersion = gpWebResult.GetLibraryVersionResult;
resolve(librayVersion);
}
});
});
} // end of GetLibraryVersion
/**
* @param {String}
* @param {Object}
* @param {Functiom} - a closure to handle the client stuff
* @param {String} - The error String filled if the client creation fails
* @return {soapClient} - The soap client which will be an object if the creatClient call succeeds
*/
soap.createClient(url, options, function(err, client) {
var libraryVersion ="";
if (err) {
console.log(err);
process.exit(-1);
}
client.setSecurity(wsSecurity);
var initializePromise = GetLibraryVersion(client);
initializePromise.then(function(gpWebResult) {
libraryVersion = gpWebResult;
console.log(libraryVersion);
}, errHandler);
});