diff --git a/lib/command-handler/index.js b/lib/command-handler/index.js index 485c428..1b872e3 100644 --- a/lib/command-handler/index.js +++ b/lib/command-handler/index.js @@ -19,6 +19,7 @@ const handlerDownlineInfo = require('./downlineinfo'); const handlerEnableDownline = require('./enabledownline'); const handlerHelp = require('./help'); const handlerInquiry = require('./inquiry'); +const handlerListComplain = require('./listcomplain'); const handlerListDeposit = require('./listdeposit'); const handlerListDownline = require('./listdownline'); const handlerListTerminal = require('./listterminal'); @@ -110,6 +111,9 @@ function execute(msg, params, cb) { else if (commandGroup === 'complain') { handlerComplain(tokens, params, cb); } + else if (commandGroup === 'listcomplain') { + handlerListComplain(tokens, params, cb); + } else if (commandGroup === 'help') { handlerHelp(tokens, params, cb) } diff --git a/lib/command-handler/listcomplain.js b/lib/command-handler/listcomplain.js new file mode 100644 index 0000000..5c09e71 --- /dev/null +++ b/lib/command-handler/listcomplain.js @@ -0,0 +1,32 @@ +const CORE_ENDPOINT = '/complains'; + +const commandError = require('./error'); +const coreapi = require('../coreapi'); + +function help(keyword) { + return `Untuk melihat keluhan yg telah dibuat,\nketik perintah dengan format: ${ keyword.toUpperCase() }.<PIN>`; +} + +function execute(tokens, params, cb) { + + if (!tokens || tokens.length < 2) { + const responseParams = { + body: `${ commandError.ERR_INVALID_FORMAT }. ${ help(tokens[0]) }` + } + + cb(null, null, responseParams); + return; + } + + const coreParams = { + asker_terminal_name: params.from, + asker_terminal_password: tokens[1], + origin: params.origin, + report_ip: params.report_ip, + report_port: params.report_port, + }; + + coreapi(CORE_ENDPOINT, coreParams, 'GET', cb); +} + +module.exports = execute; \ No newline at end of file diff --git a/lib/default-command.js b/lib/default-command.js index 521ee2e..c7b998d 100644 --- a/lib/default-command.js +++ b/lib/default-command.js @@ -238,6 +238,13 @@ module.exports = { 'komplain', 'komplen', ], + listcomplain: [ + 'complains', + 'complainlist', + 'listcomplain', + 'listkomplain', + 'listkomplen', + ], inquiry: [ 'cektagihan', 'infotagihan',