Commit 81df4efb46c1b388e0d6894c10fd8e6372c17cee
1 parent
e287f4b4c8
Exists in
master
temporary bonus
Showing 3 changed files with 40 additions and 0 deletions Side-by-side Diff
lib/command-handler/index.js
... | ... | @@ -24,6 +24,7 @@ const handlerListTerminal = require('./listterminal'); |
24 | 24 | const handlerListTrx = require('./listtrx'); |
25 | 25 | const handlerPrice = require('./price'); |
26 | 26 | const handlerSupplierBalances = require('./supplierbalances'); |
27 | +const handlerTemporaryBonus = require('./temporarybonus'); | |
27 | 28 | const handlerTransferBalance = require('./transferbalance'); |
28 | 29 | |
29 | 30 | function execute(msg, params, cb) { |
... | ... | @@ -92,6 +93,9 @@ function execute(msg, params, cb) { |
92 | 93 | else if (commandGroup === 'supplierbalances') { |
93 | 94 | handlerSupplierBalances(tokens, params, cb); |
94 | 95 | } |
96 | + else if (commandGroup === 'temporarybonus') { | |
97 | + handlerTemporaryBonus(tokens, params, cb); | |
98 | + } | |
95 | 99 | else if (commandGroup === 'help') { |
96 | 100 | handlerHelp(tokens, params, cb) |
97 | 101 | } |
lib/command-handler/temporarybonus.js
... | ... | @@ -0,0 +1,29 @@ |
1 | +const coreEndpoint = '/stores/temporary-bonus'; | |
2 | + | |
3 | +const commandError = require('./error'); | |
4 | +const coreapi = require('../coreapi'); | |
5 | + | |
6 | +function help(keyword) { | |
7 | + return `Untuk mengecek bonus yamg belum dibagikan, ketik 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 | + }; | |
25 | + | |
26 | + coreapi(coreEndpoint, coreParams, 'GET', cb); | |
27 | +} | |
28 | + | |
29 | +module.exports = execute; | |
0 | 30 | \ No newline at end of file |
lib/default-command.js