Compare View
Commits (2)
Changes
Showing 5 changed files Side-by-side Diff
lib/command-handler/index.js
... | ... | @@ -19,6 +19,7 @@ const handlerDownlineInfo = require('./downlineinfo'); |
19 | 19 | const handlerEnableDownline = require('./enabledownline'); |
20 | 20 | const handlerHelp = require('./help'); |
21 | 21 | const handlerInquiry = require('./inquiry'); |
22 | +const handlerListComplain = require('./listcomplain'); | |
22 | 23 | const handlerListDeposit = require('./listdeposit'); |
23 | 24 | const handlerListDownline = require('./listdownline'); |
24 | 25 | const handlerListTerminal = require('./listterminal'); |
... | ... | @@ -110,6 +111,9 @@ function execute(msg, params, cb) { |
110 | 111 | else if (commandGroup === 'complain') { |
111 | 112 | handlerComplain(tokens, params, cb); |
112 | 113 | } |
114 | + else if (commandGroup === 'listcomplain') { | |
115 | + handlerListComplain(tokens, params, cb); | |
116 | + } | |
113 | 117 | else if (commandGroup === 'help') { |
114 | 118 | handlerHelp(tokens, params, cb) |
115 | 119 | } |
lib/command-handler/listcomplain.js
... | ... | @@ -0,0 +1,32 @@ |
1 | +const CORE_ENDPOINT = '/complains'; | |
2 | + | |
3 | +const commandError = require('./error'); | |
4 | +const coreapi = require('../coreapi'); | |
5 | + | |
6 | +function help(keyword) { | |
7 | + return `Untuk melihat keluhan yg telah dibuat,\nketik perintah dengan format: ${ keyword.toUpperCase() }.<PIN>`; | |
8 | +} | |
9 | + | |
10 | +function execute(tokens, params, cb) { | |
11 | + | |
12 | + if (!tokens || tokens.length < 2) { | |
13 | + const responseParams = { | |
14 | + body: `${ commandError.ERR_INVALID_FORMAT }. ${ help(tokens[0]) }` | |
15 | + } | |
16 | + | |
17 | + cb(null, null, responseParams); | |
18 | + return; | |
19 | + } | |
20 | + | |
21 | + const coreParams = { | |
22 | + asker_terminal_name: params.from, | |
23 | + asker_terminal_password: tokens[1], | |
24 | + origin: params.origin, | |
25 | + report_ip: params.report_ip, | |
26 | + report_port: params.report_port, | |
27 | + }; | |
28 | + | |
29 | + coreapi(CORE_ENDPOINT, coreParams, 'GET', cb); | |
30 | +} | |
31 | + | |
32 | +module.exports = execute; | |
0 | 33 | \ No newline at end of file |
lib/default-command.js
package-lock.json