diff --git a/lib/command-handler/index.js b/lib/command-handler/index.js index 787da16..3b564fe 100644 --- a/lib/command-handler/index.js +++ b/lib/command-handler/index.js @@ -24,6 +24,7 @@ const handlerListTerminal = require('./listterminal'); const handlerListTrx = require('./listtrx'); const handlerPrice = require('./price'); const handlerSupplierBalances = require('./supplierbalances'); +const handlerTemporaryBonus = require('./temporarybonus'); const handlerTransferBalance = require('./transferbalance'); function execute(msg, params, cb) { @@ -92,6 +93,9 @@ function execute(msg, params, cb) { else if (commandGroup === 'supplierbalances') { handlerSupplierBalances(tokens, params, cb); } + else if (commandGroup === 'temporarybonus') { + handlerTemporaryBonus(tokens, params, cb); + } else if (commandGroup === 'help') { handlerHelp(tokens, params, cb) } diff --git a/lib/command-handler/temporarybonus.js b/lib/command-handler/temporarybonus.js new file mode 100644 index 0000000..82bf53d --- /dev/null +++ b/lib/command-handler/temporarybonus.js @@ -0,0 +1,29 @@ +const coreEndpoint = '/stores/temporary-bonus'; + +const commandError = require('./error'); +const coreapi = require('../coreapi'); + +function help(keyword) { + return `Untuk mengecek bonus yamg belum dibagikan, ketik 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], + }; + + 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 b9a25e6..acb6356 100644 --- a/lib/default-command.js +++ b/lib/default-command.js @@ -215,6 +215,13 @@ module.exports = { 'listtrxall', 'listtransaksiall', ], + temporarybonus: [ + 'bonus', + 'bonustemp', + 'bonustemporary', + 'tempbonus', + 'temporarybonus' + ], _setmarkup: [ 'markup' ],