Commit ff9c0a476dd9c865e31aa237fb576cf40fccfeb7

Authored by Adhidarma Hadiwinoto
1 parent d33888983e
Exists in master

LISTDEPOSIT

Showing 3 changed files with 55 additions and 0 deletions Side-by-side Diff

lib/command-handler/index.js
... ... @@ -18,6 +18,7 @@ const handlerDisableDownline = require('./disabledownline');
18 18 const handlerDownlineInfo = require('./downlineinfo');
19 19 const handlerEnableDownline = require('./enabledownline');
20 20 const handlerHelp = require('./help');
  21 +const handlerListDeposit = require('./listdeposit');
21 22 const handlerListDownline = require('./listdownline');
22 23 const handlerListTerminal = require('./listterminal');
23 24 const handlerListTrx = require('./listtrx');
... ... @@ -67,6 +68,9 @@ function execute(msg, params, cb) {
67 68 else if (commandGroup === 'listtrx' || commandGroup === 'listtrxall') {
68 69 handlerListTrx(tokens, params, cb);
69 70 }
  71 + else if (commandGroup === 'listdeposit') {
  72 + handlerListDeposit(tokens, params, cb);
  73 + }
70 74 else if (commandGroup === 'addterminal') {
71 75 handlerAddTerminal(tokens, params, cb);
72 76 }
lib/command-handler/listdeposit.js
... ... @@ -0,0 +1,39 @@
  1 +const coreEndpoint = '/histories/mutations/deposit-and-transfer';
  2 +
  3 +const commandError = require('./error');
  4 +const coreapi = require('../coreapi');
  5 +
  6 +function help(keyword) {
  7 + return `
  8 +Format perintah utk list deposit dan transfer:
  9 +
  10 +${ keyword.toUpperCase() }.<PIN> atau ${ keyword.toUpperCase() }.<TANGGAL>.<PIN>.
  11 +
  12 +<TANGGAL> dlm format YYYY-MM-DD, contoh 2018-12-31 untuk tanggal 31 Desember 2018.
  13 + `.trim();
  14 +}
  15 +
  16 +function execute(tokens, params, cb) {
  17 +
  18 + if (!tokens || tokens.length < 2) {
  19 + const responseParams = {
  20 + body: `${ commandError.ERR_INVALID_FORMAT }. ${ help(tokens[0]) }`
  21 + }
  22 +
  23 + cb(null, null, responseParams);
  24 + return;
  25 + }
  26 +
  27 + const idxPin = tokens.length < 3 ? 1 : 2;
  28 +
  29 + const coreParams = {
  30 + origin: params.origin,
  31 + asker_terminal_name: params.from,
  32 + asker_terminal_password: tokens[idxPin],
  33 + created_date: tokens.length < 3 ? null : tokens[1],
  34 + };
  35 +
  36 + coreapi(coreEndpoint, coreParams, 'GET', cb);
  37 +}
  38 +
  39 +module.exports = execute;
0 40 \ No newline at end of file
lib/default-command.js
... ... @@ -152,6 +152,18 @@ module.exports = {
152 152 'tiket',
153 153 'tiketdeposit',
154 154 ],
  155 + listdeposit: [
  156 + 'depolist',
  157 + 'depositlist',
  158 + 'listdepo',
  159 + 'listdeposit',
  160 + 'listtransfer',
  161 + 'listtrf',
  162 + 'rekapdepo',
  163 + 'rekapdeposit',
  164 + 'rekaptransfer',
  165 + 'rekaptrf',
  166 + ],
155 167 listterminal: [
156 168 'listmsisdn',
157 169 'listterminal',