Commit 38bf7cc689e45eb94706556cbf3e85e4c35338f3
1 parent
83d8524480
Exists in
master
advise.js
Showing 3 changed files with 55 additions and 1 deletions Side-by-side Diff
advice.js
... | ... | @@ -0,0 +1,52 @@ |
1 | +var xmlrpc = require('xmlrpc'); | |
2 | +var url = require('url'); | |
3 | + | |
4 | +function topupInquiry(url, requestId, msisdn, pin, destination) { | |
5 | + var parsedUrl = url.parse(config.h2h_out.partner); | |
6 | + | |
7 | + var clientOptions = { | |
8 | + url: url | |
9 | + }; | |
10 | + | |
11 | + var client; | |
12 | + if (parsedUrl.protocol == 'https:') { | |
13 | + client = xmlrpc.createSecureClient(clientOptions); | |
14 | + } else { | |
15 | + client = xmlrpc.createClient(clientOptions); | |
16 | + } | |
17 | + | |
18 | + var params = { | |
19 | + MSISDN: msisdn, | |
20 | + REQUESTID: requestId, | |
21 | + PIN: pin, | |
22 | + NOHP: destination, | |
23 | + }; | |
24 | + | |
25 | + console.log('Calling topUpInquiry method'); | |
26 | + client.methodCall('topUpInquiry', [ params ], function (error, value) { | |
27 | + if (error) { | |
28 | + console.log('Error', error); | |
29 | + return; | |
30 | + } | |
31 | + console.log(value); | |
32 | + }); | |
33 | + | |
34 | +} | |
35 | + | |
36 | +var fs = require('fs'); | |
37 | +var ini = require('ini'); | |
38 | +var config = ini.parse(fs.readFileSync(__dirname + '/config.ini', 'utf-8')); | |
39 | + | |
40 | +var argv = require('minimist')(process.argv.slice(2)); | |
41 | + | |
42 | +if (!argv.destination || argv.destination === true) { | |
43 | + console.log('Missing "destination" parameter'); | |
44 | + process.exit(1); | |
45 | +} | |
46 | + | |
47 | +if (!argv.requestid || argv.requestid === true) { | |
48 | + console.log('Missing "requestid" parameter'); | |
49 | + process.exit(1); | |
50 | +} | |
51 | + | |
52 | +topupInquiry(config.h2h_out.partner, argv.requestid, config.h2h_out.userid, config.h2h_out.password, argv.destination); |
package.json
... | ... | @@ -30,6 +30,7 @@ |
30 | 30 | "sate24": "git+http://gitlab.kodesumber.com/reload97/node-sate24.git", |
31 | 31 | "winston": "~1.0.1", |
32 | 32 | "ini": "~1.3.4", |
33 | - "sate24-expresso": "git+http://gitlab.kodesumber.com/reload97/sate24-expresso.git" | |
33 | + "sate24-expresso": "git+http://gitlab.kodesumber.com/reload97/sate24-expresso.git", | |
34 | + "minimist": "~1.2.0" | |
34 | 35 | } |
35 | 36 | } |
xmlout.js