From a6fbe088d9cd9ae1a5fee54e44d84b6b6487f849 Mon Sep 17 00:00:00 2001 From: Adhidarma Hadiwinoto <me@adhisimon.org> Date: Mon, 16 Dec 2019 18:56:23 +0700 Subject: [PATCH] claimbonus --- lib/command-handler/claimbonus.js | 29 +++++++++++++++++++++++++++++ lib/command-handler/index.js | 4 ++++ lib/default-command.js | 10 ++++++++++ 3 files changed, 43 insertions(+) create mode 100644 lib/command-handler/claimbonus.js diff --git a/lib/command-handler/claimbonus.js b/lib/command-handler/claimbonus.js new file mode 100644 index 0000000..e0b7d11 --- /dev/null +++ b/lib/command-handler/claimbonus.js @@ -0,0 +1,29 @@ +const coreEndpoint = '/rebate/claim-store'; + +const commandError = require('./error'); +const coreapi = require('../coreapi'); + +function help(keyword) { + return `Untuk menarik bonus ke saldo, ketik perintah dengan format:\n${ 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/command-handler/index.js b/lib/command-handler/index.js index 3b564fe..d6f4fb3 100644 --- a/lib/command-handler/index.js +++ b/lib/command-handler/index.js @@ -12,6 +12,7 @@ const handlerAddTerminal = require('./addterminal'); const handlerBalance = require('./balance'); const handlerBuy = require('./buy'); const handlerChangePin = require('./changepin'); +const handlerClaimBonus = require('./claimbonus'); const handlerDaySummary = require('./daysummary'); const handlerDepositTicket = require('./depositticket'); const handlerDisableDownline = require('./disabledownline'); @@ -93,6 +94,9 @@ function execute(msg, params, cb) { else if (commandGroup === 'supplierbalances') { handlerSupplierBalances(tokens, params, cb); } + else if (commandGroup === 'claimbonus') { + handlerClaimBonus(tokens, params, cb); + } else if (commandGroup === 'temporarybonus') { handlerTemporaryBonus(tokens, params, cb); } diff --git a/lib/default-command.js b/lib/default-command.js index acb6356..2bedd99 100644 --- a/lib/default-command.js +++ b/lib/default-command.js @@ -222,6 +222,16 @@ module.exports = { 'tempbonus', 'temporarybonus' ], + claimbonus: [ + 'ambilbonus', + 'ambilrebate', + 'bonusclaim', + 'claimbonus', + 'claimrebate', + 'rebateclaim', + 'tarikbonus', + 'tarikrebate', + ], _setmarkup: [ 'markup' ], -- 1.9.0