Commit f77a8568e30a18e3b94eadac525a8244bb955f47

Authored by Adhidarma Hadiwinoto
1 parent ff7894b62a
Exists in master

Enable/disable downline

Showing 5 changed files with 77 additions and 3 deletions Side-by-side Diff

lib/command-handler/disabledownline.js
... ... @@ -0,0 +1,33 @@
  1 +"use strict";
  2 +
  3 +const coreEndpoint = '/stores/disable';
  4 +
  5 +const commandError = require('./error');
  6 +const coreapi = require('../coreapi');
  7 +
  8 +function help(keyword) {
  9 + return `Untuk menonaktifkan 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 + origin: params.origin,
  25 + asker_terminal_name: params.from,
  26 + store_id: tokens[1].replace(/^#/, ''),
  27 + asker_terminal_password: tokens[2]
  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/enabledownline.js
... ... @@ -0,0 +1,33 @@
  1 +"use strict";
  2 +
  3 +const coreEndpoint = '/stores/enable';
  4 +
  5 +const commandError = require('./error');
  6 +const coreapi = require('../coreapi');
  7 +
  8 +function help(keyword) {
  9 + return `Untuk mengaktifkan kembali 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 + origin: params.origin,
  25 + asker_terminal_name: params.from,
  26 + store_id: tokens[1].replace(/^#/, ''),
  27 + asker_terminal_password: tokens[2]
  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
... ... @@ -18,6 +18,8 @@ const handlerTransferBalance = require(&#39;./transferbalance&#39;);
18 18 const handlerListTerminal = require('./listterminal');
19 19 const handlerAddTerminal = require('./addterminal');
20 20 const handlerChangePin = require('./changepin');
  21 +const handlerEnableDownline = require('./enabledownline');
  22 +const handlerDisableDownline = require('./disabledownline');
21 23  
22 24 function execute(msg, params, cb) {
23 25  
... ... @@ -63,6 +65,12 @@ function execute(msg, params, cb) {
63 65 else if (commandGroup === 'changepin') {
64 66 handlerChangePin(tokens, params, cb);
65 67 }
  68 + else if (commandGroup === 'enabledownline') {
  69 + handlerEnableDownline(tokens, params, cb);
  70 + }
  71 + else if (commandGroup === 'disabledownline') {
  72 + handlerDisableDownline(tokens, params, cb);
  73 + }
66 74 else if (commandGroup === 'help') {
67 75 handlerHelp(cb)
68 76 }
lib/coreapi/core-version.js
1 1 "use strict";
2 2  
3   -const MINIMUM_VERSION = 'v1.33.1-29';
  3 +const MINIMUM_VERSION = 'v1.33.1-30';
4 4  
5 5 const util = require('util');
6 6 const naturalCompare = require('natural-compare-lite');
lib/default-command.js
... ... @@ -74,7 +74,7 @@ module.exports = {
74 74 "sd",
75 75 "sdl",
76 76 ],
77   - _disabledownline: [
  77 + disabledownline: [
78 78 "disabledl",
79 79 "disabledownline",
80 80 "disablemitra",
... ... @@ -85,7 +85,7 @@ module.exports = {
85 85 "nonaktifkanmitra",
86 86 "nonaktifmitra",
87 87 ],
88   - _enabledownline: [
  88 + enabledownline: [
89 89 "aktifkandl",
90 90 "aktifkandownline",
91 91 "aktifkanmitra",