Commit 8e3a1cb0d93b5851475ccdeced9d3271e08d5bb2

Authored by Adhidarma Hadiwinoto
1 parent ed78c0ab31
Exists in master

Info downline

Showing 3 changed files with 40 additions and 1 deletions Side-by-side Diff

lib/command-handler/downlineinfo.js
... ... @@ -0,0 +1,33 @@
  1 +"use strict";
  2 +
  3 +const commandError = require('./error');
  4 +const coreapi = require('../coreapi');
  5 +
  6 +const coreEndpoint = '/stores/view';
  7 +
  8 +function help(keyword) {
  9 + return `Untuk info sebuah downline, ketik perintah dengan format: ${ keyword.toUpperCase() }.#<IDDOWNLINE>.<PIN>`;
  10 +}
  11 +
  12 +function execute(tokens, params, cb) {
  13 +
  14 + if (!tokens || tokens.length < 3) {
  15 + const responseParams = {
  16 + body: `${ commandError.ERR_INVALID_FORMAT }. ${ help(tokens[0]) }`
  17 + }
  18 +
  19 + cb(null, null, responseParams);
  20 + return;
  21 + }
  22 +
  23 + const coreParams = {
  24 + terminal_name: params.from,
  25 + downline_store_id: tokens[1].replace(/^#/, ''),
  26 + password: tokens[2],
  27 + postpaid: 0
  28 + };
  29 +
  30 + coreapi(coreEndpoint, coreParams, 'GET', cb);
  31 +}
  32 +
  33 +module.exports = execute;
0 34 \ No newline at end of file
lib/command-handler/index.js
... ... @@ -11,6 +11,7 @@ const handlerBuy = require(&#39;./buy&#39;);
11 11 const handlerBalance = require('./balance');
12 12 const handlerPrice = require('./price');
13 13 const handlerListDownline = require('./listdownline');
  14 +const handlerDownlineInfo = require('./downlineinfo');
14 15  
15 16 function execute(msg, params, cb) {
16 17  
... ... @@ -35,6 +36,9 @@ function execute(msg, params, cb) {
35 36 else if (commandGroup === 'listdownline') {
36 37 handlerListDownline(tokens, params, cb);
37 38 }
  39 + else if (commandGroup === 'downlineinfo') {
  40 + handlerDownlineInfo(tokens, params, cb);
  41 + }
38 42 else if (commandGroup === 'help') {
39 43 handlerHelp(cb)
40 44 }
lib/default-command.js
... ... @@ -43,9 +43,11 @@ module.exports = {
43 43 "dllist",
44 44 "ldl"
45 45 ],
46   - _downlineinfo: [
  46 + downlineinfo: [
47 47 "downline",
  48 + "dl",
48 49 "sd",
  50 + "sdl",
49 51 "saldodownline",
50 52 "mitra",
51 53 "saldomitra"