diff --git a/lib/command-handler/index.js b/lib/command-handler/index.js index 828d46a..3736514 100644 --- a/lib/command-handler/index.js +++ b/lib/command-handler/index.js @@ -18,6 +18,7 @@ const handlerDisableDownline = require('./disabledownline'); const handlerDownlineInfo = require('./downlineinfo'); const handlerEnableDownline = require('./enabledownline'); const handlerHelp = require('./help'); +const handlerListDeposit = require('./listdeposit'); const handlerListDownline = require('./listdownline'); const handlerListTerminal = require('./listterminal'); const handlerListTrx = require('./listtrx'); @@ -67,6 +68,9 @@ function execute(msg, params, cb) { else if (commandGroup === 'listtrx' || commandGroup === 'listtrxall') { handlerListTrx(tokens, params, cb); } + else if (commandGroup === 'listdeposit') { + handlerListDeposit(tokens, params, cb); + } else if (commandGroup === 'addterminal') { handlerAddTerminal(tokens, params, cb); } diff --git a/lib/command-handler/listdeposit.js b/lib/command-handler/listdeposit.js new file mode 100644 index 0000000..78700c6 --- /dev/null +++ b/lib/command-handler/listdeposit.js @@ -0,0 +1,39 @@ +const coreEndpoint = '/histories/mutations/deposit-and-transfer'; + +const commandError = require('./error'); +const coreapi = require('../coreapi'); + +function help(keyword) { + return ` +Format perintah utk list deposit dan transfer: + +${ keyword.toUpperCase() }.<PIN> atau ${ keyword.toUpperCase() }.<TANGGAL>.<PIN>. + +<TANGGAL> dlm format YYYY-MM-DD, contoh 2018-12-31 untuk tanggal 31 Desember 2018. + `.trim(); +} + +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 idxPin = tokens.length < 3 ? 1 : 2; + + const coreParams = { + origin: params.origin, + asker_terminal_name: params.from, + asker_terminal_password: tokens[idxPin], + created_date: tokens.length < 3 ? null : tokens[1], + }; + + coreapi(coreEndpoint, 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 50c993c..2864273 100644 --- a/lib/default-command.js +++ b/lib/default-command.js @@ -152,6 +152,18 @@ module.exports = { 'tiket', 'tiketdeposit', ], + listdeposit: [ + 'depolist', + 'depositlist', + 'listdepo', + 'listdeposit', + 'listtransfer', + 'listtrf', + 'rekapdepo', + 'rekapdeposit', + 'rekaptransfer', + 'rekaptrf', + ], listterminal: [ 'listmsisdn', 'listterminal',