Compare View
Commits (7)
Changes
Showing 11 changed files Side-by-side Diff
config.sample.json
lib/command-handler/addterminal.js
... | ... | @@ -31,7 +31,7 @@ function execute(tokens, params, cb) { |
31 | 31 | password: tokens.length < 5 ? tokens[2] : tokens[3] |
32 | 32 | }; |
33 | 33 | |
34 | - if (typeof coreParams.terminal_name === 'string' && common.isPhoneNumber(coreParams.terminal_name) && coreParams.indexOf('0') === 0) { | |
34 | + if (typeof coreParams.terminal_name === 'string' && common.isPhoneNumber(coreParams.terminal_name) && coreParams.terminal_name.indexOf('0') === 0) { | |
35 | 35 | coreParams.terminal_name = coreParams.terminal_name.replace(/^0/, '62'); |
36 | 36 | } |
37 | 37 |
lib/command-handler/buy.js
... | ... | @@ -41,7 +41,7 @@ function execute(tokens, params, cb) { |
41 | 41 | product_name: tokens[1].toUpperCase(), |
42 | 42 | destination: tokens[2].replace(/^\+62/, '0'), |
43 | 43 | password: tokens[3], |
44 | - request_id: tokens[4] || generateRequestId(tokens[1], tokens[2]), | |
44 | + request_id: `${generateRequestId(tokens[1], tokens[2])}${Number(tokens[4]) ? '_req' + Number(tokens[4]) : ''}`, | |
45 | 45 | postpaid: 0 |
46 | 46 | }; |
47 | 47 |
lib/command-handler/daysummary.js
... | ... | @@ -26,7 +26,8 @@ function execute(tokens, params, cb) { |
26 | 26 | origin: params.origin, |
27 | 27 | asker_terminal_name: params.from, |
28 | 28 | asker_terminal_password: tokens[idxPin], |
29 | - created_date: tokens.length < 3 ? null : tokens[1] | |
29 | + created_date: tokens.length < 3 ? null : tokens[1], | |
30 | + include_downline: params.commandGroup === 'daysummaryall', | |
30 | 31 | }; |
31 | 32 | |
32 | 33 | coreapi(coreEndpoint, coreParams, 'GET', cb); |
lib/command-handler/help.js
1 | +const config = require('komodo-sdk/config'); | |
1 | 2 | const logger = require('komodo-sdk/logger'); |
2 | 3 | const commands = require('../command-group'); |
3 | 4 | |
... | ... | @@ -27,10 +28,14 @@ const msg = 'Perintah tersedia:\n\n' + cmds2.join(',\n\n'); |
27 | 28 | |
28 | 29 | logger.verbose('Help return message constructed', { count: cmds.length, chars: msg.length, lines: msg.split(/\r\n|\r|\n/).length }); |
29 | 30 | |
30 | -module.exports = function(cb) { | |
31 | +module.exports = function(tokens, params, cb) { | |
32 | + const blacklisted = ((config.blacklist_help_for_origins || []).indexOf(params.origin || '') >= 0) | |
33 | + || ((config.blacklist_help_for_origin_transports || []).indexOf(params.origin_transport || '') >= 0) | |
34 | + ; | |
31 | 35 | |
36 | + const body = blacklisted ? `Perintah "${tokens[0]}" tdk tersedia pd jalur SMS dan sejenis.` : msg; | |
32 | 37 | const responseParams = { |
33 | - body: msg | |
38 | + body | |
34 | 39 | } |
35 | 40 | |
36 | 41 | cb(null, null, responseParams); |
lib/command-handler/index.js
... | ... | @@ -18,6 +18,7 @@ const handlerDisableDownline = require('./disabledownline'); |
18 | 18 | const handlerDownlineInfo = require('./downlineinfo'); |
19 | 19 | const handlerEnableDownline = require('./enabledownline'); |
20 | 20 | const handlerHelp = require('./help'); |
21 | +const handlerListDeposit = require('./listdeposit'); | |
21 | 22 | const handlerListDownline = require('./listdownline'); |
22 | 23 | const handlerListTerminal = require('./listterminal'); |
23 | 24 | const handlerListTrx = require('./listtrx'); |
... | ... | @@ -67,6 +68,9 @@ function execute(msg, params, cb) { |
67 | 68 | else if (commandGroup === 'listtrx' || commandGroup === 'listtrxall') { |
68 | 69 | handlerListTrx(tokens, params, cb); |
69 | 70 | } |
71 | + else if (commandGroup === 'listdeposit') { | |
72 | + handlerListDeposit(tokens, params, cb); | |
73 | + } | |
70 | 74 | else if (commandGroup === 'addterminal') { |
71 | 75 | handlerAddTerminal(tokens, params, cb); |
72 | 76 | } |
... | ... | @@ -76,7 +80,7 @@ function execute(msg, params, cb) { |
76 | 80 | else if (commandGroup === 'enabledownline') { |
77 | 81 | handlerEnableDownline(tokens, params, cb); |
78 | 82 | } |
79 | - else if (commandGroup === 'daysummary') { | |
83 | + else if (commandGroup === 'daysummary' || commandGroup === 'daysummaryall') { | |
80 | 84 | handlerDaySummary(tokens, params, cb); |
81 | 85 | } |
82 | 86 | else if (commandGroup === 'depositticket') { |
... | ... | @@ -89,7 +93,7 @@ function execute(msg, params, cb) { |
89 | 93 | handlerSupplierBalances(tokens, params, cb); |
90 | 94 | } |
91 | 95 | else if (commandGroup === 'help') { |
92 | - handlerHelp(cb) | |
96 | + handlerHelp(tokens, params, cb) | |
93 | 97 | } |
94 | 98 | else { |
95 | 99 | cb(commandError.ERR_NOT_IMPLEMENTED); |
lib/command-handler/listdeposit.js
... | ... | @@ -0,0 +1,39 @@ |
1 | +const coreEndpoint = '/histories/mutations/deposit-and-transfer'; | |
2 | + | |
3 | +const commandError = require('./error'); | |
4 | +const coreapi = require('../coreapi'); | |
5 | + | |
6 | +function help(keyword) { | |
7 | + return ` | |
8 | +Format perintah utk list deposit dan transfer: | |
9 | + | |
10 | +${ keyword.toUpperCase() }.<PIN> atau ${ keyword.toUpperCase() }.<TANGGAL>.<PIN>. | |
11 | + | |
12 | +<TANGGAL> dlm format YYYY-MM-DD, contoh 2018-12-31 untuk tanggal 31 Desember 2018. | |
13 | + `.trim(); | |
14 | +} | |
15 | + | |
16 | +function execute(tokens, params, cb) { | |
17 | + | |
18 | + if (!tokens || tokens.length < 2) { | |
19 | + const responseParams = { | |
20 | + body: `${ commandError.ERR_INVALID_FORMAT }. ${ help(tokens[0]) }` | |
21 | + } | |
22 | + | |
23 | + cb(null, null, responseParams); | |
24 | + return; | |
25 | + } | |
26 | + | |
27 | + const idxPin = tokens.length < 3 ? 1 : 2; | |
28 | + | |
29 | + const coreParams = { | |
30 | + origin: params.origin, | |
31 | + asker_terminal_name: params.from, | |
32 | + asker_terminal_password: tokens[idxPin], | |
33 | + created_date: tokens.length < 3 ? null : tokens[1], | |
34 | + }; | |
35 | + | |
36 | + coreapi(coreEndpoint, coreParams, 'GET', cb); | |
37 | +} | |
38 | + | |
39 | +module.exports = execute; | |
0 | 40 | \ No newline at end of file |
lib/default-command.js
... | ... | @@ -104,7 +104,7 @@ module.exports = { |
104 | 104 | "laporan", |
105 | 105 | "rekap", |
106 | 106 | ], |
107 | - _daysummaryall: [ | |
107 | + daysummaryall: [ | |
108 | 108 | "lapall", |
109 | 109 | "laporanall", |
110 | 110 | "rekapall", |
... | ... | @@ -152,6 +152,20 @@ module.exports = { |
152 | 152 | 'tiket', |
153 | 153 | 'tiketdeposit', |
154 | 154 | ], |
155 | + listdeposit: [ | |
156 | + 'depolist', | |
157 | + 'depositlist', | |
158 | + 'listdepo', | |
159 | + 'listdeposit', | |
160 | + 'listtransfer', | |
161 | + 'listtrf', | |
162 | + 'rekapdepo', | |
163 | + 'rekapdeposit', | |
164 | + 'rekaptransfer', | |
165 | + 'rekaptrf', | |
166 | + 'transferlist', | |
167 | + 'trflist', | |
168 | + ], | |
155 | 169 | listterminal: [ |
156 | 170 | 'listmsisdn', |
157 | 171 | 'listterminal', |
lib/http-listener.js
... | ... | @@ -97,6 +97,7 @@ function mainHandler(req, res) { |
97 | 97 | |
98 | 98 | const params = { |
99 | 99 | origin: req.body.origin || req.query.origin || 'MESSAGING', |
100 | + origin_transport: req.body.origin_transport || req.query.origin_transport, | |
100 | 101 | report_ip: req.body.report_ip || req.query.report_ip || req.ip, |
101 | 102 | report_port: req.body.report_port || req.query.report_port, |
102 | 103 | from: req.body.partner || req.query.partner || req.body.from || req.query.from, |
package-lock.json