Commit 8e3a1cb0d93b5851475ccdeced9d3271e08d5bb2

Authored by Adhidarma Hadiwinoto
1 parent ed78c0ab31
Exists in master

Info downline

Showing 3 changed files with 40 additions and 1 deletions Inline Diff

lib/command-handler/downlineinfo.js
File was created 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;
lib/command-handler/index.js
1 "use strict"; 1 "use strict";
2 2
3 const logger = require('komodo-sdk/logger'); 3 const logger = require('komodo-sdk/logger');
4 4
5 const commandParser = require('../command-parser'); 5 const commandParser = require('../command-parser');
6 6
7 const commandError = require('./error'); 7 const commandError = require('./error');
8 8
9 const handlerHelp = require('./help'); 9 const handlerHelp = require('./help');
10 const handlerBuy = require('./buy'); 10 const handlerBuy = require('./buy');
11 const handlerBalance = require('./balance'); 11 const handlerBalance = require('./balance');
12 const handlerPrice = require('./price'); 12 const handlerPrice = require('./price');
13 const handlerListDownline = require('./listdownline'); 13 const handlerListDownline = require('./listdownline');
14 const handlerDownlineInfo = require('./downlineinfo');
14 15
15 function execute(msg, params, cb) { 16 function execute(msg, params, cb) {
16 17
17 if ( typeof msg !== 'string' || !msg.trim() ) { 18 if ( typeof msg !== 'string' || !msg.trim() ) {
18 cb(commandError.ERR_EMPTY_MESSAGE); 19 cb(commandError.ERR_EMPTY_MESSAGE);
19 return; 20 return;
20 } 21 }
21 22
22 const tokens = commandParser.splitToken(msg); 23 const tokens = commandParser.splitToken(msg);
23 const commandGroup = commandParser.extractCommandGroup(tokens); 24 const commandGroup = commandParser.extractCommandGroup(tokens);
24 logger.verbose('Got new message from partner', {msg: msg, params: params, tokens: tokens, commandGroup: commandGroup}); 25 logger.verbose('Got new message from partner', {msg: msg, params: params, tokens: tokens, commandGroup: commandGroup});
25 26
26 if (!commandGroup || commandGroup === 'buy') { 27 if (!commandGroup || commandGroup === 'buy') {
27 handlerBuy(tokens, params, cb); 28 handlerBuy(tokens, params, cb);
28 } 29 }
29 else if (commandGroup === 'balance') { 30 else if (commandGroup === 'balance') {
30 handlerBalance(tokens, params, cb); 31 handlerBalance(tokens, params, cb);
31 } 32 }
32 else if (commandGroup === 'price') { 33 else if (commandGroup === 'price') {
33 handlerPrice(tokens, params, cb); 34 handlerPrice(tokens, params, cb);
34 } 35 }
35 else if (commandGroup === 'listdownline') { 36 else if (commandGroup === 'listdownline') {
36 handlerListDownline(tokens, params, cb); 37 handlerListDownline(tokens, params, cb);
37 } 38 }
39 else if (commandGroup === 'downlineinfo') {
40 handlerDownlineInfo(tokens, params, cb);
41 }
38 else if (commandGroup === 'help') { 42 else if (commandGroup === 'help') {
39 handlerHelp(cb) 43 handlerHelp(cb)
40 } 44 }
41 else { 45 else {
42 cb(commandError.ERR_NOT_IMPLEMENTED); 46 cb(commandError.ERR_NOT_IMPLEMENTED);
43 } 47 }
44 } 48 }
45 49
46 module.exports = execute; 50 module.exports = execute;
lib/default-command.js
1 module.exports = { 1 module.exports = {
2 help: [ 2 help: [
3 "help", 3 "help",
4 "bantu", 4 "bantu",
5 "bantuan", 5 "bantuan",
6 "format", 6 "format",
7 "tolong", 7 "tolong",
8 "test" 8 "test"
9 ], 9 ],
10 buy: [ 10 buy: [
11 "buy", 11 "buy",
12 "isi", 12 "isi",
13 "beli", 13 "beli",
14 "i" 14 "i"
15 ], 15 ],
16 _statuscheck: [ 16 _statuscheck: [
17 "status", 17 "status",
18 "cekstatus", 18 "cekstatus",
19 "checkstatus" 19 "checkstatus"
20 ], 20 ],
21 balance: [ 21 balance: [
22 "balance", 22 "balance",
23 "bal", 23 "bal",
24 "saldo", 24 "saldo",
25 "sal", 25 "sal",
26 "s", 26 "s",
27 "ceksaldo", 27 "ceksaldo",
28 "checksaldo" 28 "checksaldo"
29 ], 29 ],
30 _transferbalance: [ 30 _transferbalance: [
31 "transfer", 31 "transfer",
32 "trf" 32 "trf"
33 ], 33 ],
34 _addbalance: [ 34 _addbalance: [
35 "addbalance", 35 "addbalance",
36 "addbal", 36 "addbal",
37 "tambahsaldo" 37 "tambahsaldo"
38 ], 38 ],
39 listdownline: [ 39 listdownline: [
40 "listdownline", 40 "listdownline",
41 "listdl", 41 "listdl",
42 "downlinelist", 42 "downlinelist",
43 "dllist", 43 "dllist",
44 "ldl" 44 "ldl"
45 ], 45 ],
46 _downlineinfo: [ 46 downlineinfo: [
47 "downline", 47 "downline",
48 "dl",
48 "sd", 49 "sd",
50 "sdl",
49 "saldodownline", 51 "saldodownline",
50 "mitra", 52 "mitra",
51 "saldomitra" 53 "saldomitra"
52 ], 54 ],
53 _disabledownline: [ 55 _disabledownline: [
54 "disabledownline", 56 "disabledownline",
55 "disabledl", 57 "disabledl",
56 "disablemitra", 58 "disablemitra",
57 "nonaktifdownline", 59 "nonaktifdownline",
58 "nonaktifdl", 60 "nonaktifdl",
59 "nonaktifmitra", 61 "nonaktifmitra",
60 "nonaktifkandownline", 62 "nonaktifkandownline",
61 "nonaktifkandl", 63 "nonaktifkandl",
62 "nonaktifkanmitra" 64 "nonaktifkanmitra"
63 ], 65 ],
64 _enabledownline: [ 66 _enabledownline: [
65 "enabledownline", 67 "enabledownline",
66 "enabledl", 68 "enabledl",
67 "enablemitra", 69 "enablemitra",
68 "aktivasidownline", 70 "aktivasidownline",
69 "aktivasidl", 71 "aktivasidl",
70 "aktivasimitra", 72 "aktivasimitra",
71 "aktifkandownline", 73 "aktifkandownline",
72 "aktifkandl", 74 "aktifkandl",
73 "aktifkanmitra" 75 "aktifkanmitra"
74 ], 76 ],
75 _daysummary: [ 77 _daysummary: [
76 "rekap", 78 "rekap",
77 "laporan", 79 "laporan",
78 "lap" 80 "lap"
79 ], 81 ],
80 price: [ 82 price: [
81 "harga", 83 "harga",
82 "cekharga", 84 "cekharga",
83 "checkharga", 85 "checkharga",
84 "h", 86 "h",
85 "ch", 87 "ch",
86 "price", 88 "price",
87 "hargaproduk", 89 "hargaproduk",
88 "hargaproduct" 90 "hargaproduct"
89 ], 91 ],
90 _changepin: [ 92 _changepin: [
91 "pin", 93 "pin",
92 "changepin", 94 "changepin",
93 "ubahpin", 95 "ubahpin",
94 "setpin", 96 "setpin",
95 "gantipin" 97 "gantipin"
96 ], 98 ],
97 _depositticket: [ 99 _depositticket: [
98 'tiket', 100 'tiket',
99 'tiketdeposit', 101 'tiketdeposit',
100 'depo', 102 'depo',
101 'depoticket', 103 'depoticket',
102 'depositticket' 104 'depositticket'
103 ], 105 ],
104 _listterminal: [ 106 _listterminal: [
105 'listterminal', 107 'listterminal',
106 'terminallist', 108 'terminallist',
107 'lsterminal', 109 'lsterminal',
108 'terminalls', 110 'terminalls',
109 'terminalterdaftar', 111 'terminalterdaftar',
110 'terminal', 112 'terminal',
111 'msisdn', 113 'msisdn',
112 'listmsisdn', 114 'listmsisdn',
113 'msisdnlist', 115 'msisdnlist',
114 'lsmsisdn', 116 'lsmsisdn',
115 'msisdnls' 117 'msisdnls'
116 ], 118 ],
117 _addterminal: [ 119 _addterminal: [
118 'addterminal', 120 'addterminal',
119 'terminaladd', 121 'terminaladd',
120 'tambahterminal', 122 'tambahterminal',
121 'newterminal', 123 'newterminal',
122 'registerterminal', 124 'registerterminal',
123 'regterminal', 125 'regterminal',
124 'addmsisdn', 126 'addmsisdn',
125 'msisdnadd', 127 'msisdnadd',
126 'tambahmsisdn', 128 'tambahmsisdn',
127 'newmsisdn', 129 'newmsisdn',
128 'regmsisdn' 130 'regmsisdn'
129 ], 131 ],
130 _listdownlineterminal: [ 132 _listdownlineterminal: [
131 'listdownlineterminal', 133 'listdownlineterminal',
132 'listdlterminal', 134 'listdlterminal',
133 'listterminaldownline', 135 'listterminaldownline',
134 'listterminaldl', 136 'listterminaldl',
135 'listterminalmitra', 137 'listterminalmitra',
136 'listpartnerterminal', 138 'listpartnerterminal',
137 'listdownlinemsisdn', 139 'listdownlinemsisdn',
138 'listmsisdndownline', 140 'listmsisdndownline',
139 'listmsisdndl', 141 'listmsisdndl',
140 'listdlmsisdn' 142 'listdlmsisdn'
141 ], 143 ],
142 _adddownlineterminal: [ 144 _adddownlineterminal: [
143 'adddownlineterminal', 145 'adddownlineterminal',
144 'adddlterminal', 146 'adddlterminal',
145 'addpartnerterminal', 147 'addpartnerterminal',
146 'addterminalmitra', 148 'addterminalmitra',
147 'tambahterminaldownline', 149 'tambahterminaldownline',
148 'tambahterminaldl', 150 'tambahterminaldl',
149 'tambahterminalpartner', 151 'tambahterminalpartner',
150 'tambahterminalmitra', 152 'tambahterminalmitra',
151 'tambahpartnerterminal' 153 'tambahpartnerterminal'
152 ] 154 ]
153 } 155 }
154 156