Compare View

switch
from
...
to
 
Commits (9)

Changes

Showing 7 changed files Side-by-side Diff

lib/command-handler/addbalance.js
1   -"use strict";
  1 +const CORE_ENDPOINT = '/stores/add-balance';
2 2  
3 3 const commandError = require('./error');
4 4 const coreapi = require('../coreapi');
5 5  
6   -const coreEndpoint = '/stores/add-balance';
7   -
8 6 function help(keyword) {
9   - return `Untuk menambah saldo downline, ketik perintah dengan format: ${ keyword.toUpperCase() }.<IDDOWNLINE>.<JUMLAH>.<PIN>`;
  7 + return `
  8 +Untuk menambah saldo downline, ketik perintah dengan format:
  9 +
  10 +${keyword.toUpperCase()}.#<IDDOWNLINE>.<JUMLAH>.<PIN>
  11 +atau
  12 +${keyword.toUpperCase()}.<TERMINALDOWNLINE>.<JUMLAH>.<PIN>
  13 +`.trim();
10 14 }
11 15  
12 16 function execute(tokens, params, cb) {
13   -
14 17 if (!tokens || tokens.length < 4) {
15 18 const responseParams = {
16   - body: `${ commandError.ERR_INVALID_FORMAT }. ${ help(tokens[0]) }`
  19 + body: `
  20 +${commandError.ERR_INVALID_FORMAT}: ${params.msg}
  21 +
  22 +${ help(tokens[0]) }
  23 + `.trim(),
17 24 }
18 25  
19 26 cb(null, null, responseParams);
20 27 return;
21 28 }
22 29  
  30 + let destinationStoreId;
  31 + let destinationTerminalName;
  32 + if (tokens[1].indexOf('#') === 0) {
  33 + destinationStoreId = tokens[1].replace(/^#/, '');
  34 + } else {
  35 + destinationTerminalName = tokens[1];
  36 + }
  37 +
23 38 const coreParams = {
24 39 asker_terminal_name: params.from,
25   - destination_store_id: tokens[1],
  40 + destination_store_id: destinationStoreId,
  41 + destination_terminal_name: destinationTerminalName,
26 42 amount: tokens[2],
27 43 asker_terminal_password: tokens[3],
28 44 additional_note: tokens.slice(4).join(' ') || ''
29 45 };
30 46  
31   - coreapi(coreEndpoint, coreParams, 'GET', cb);
  47 + coreapi(CORE_ENDPOINT, coreParams, 'GET', cb);
32 48 }
33 49  
34 50 module.exports = execute;
35 51 \ No newline at end of file
lib/command-handler/downlineinfo.js
1   -"use strict";
  1 +const CORE_ENDPOINT = '/stores/view';
2 2  
3 3 const commandError = require('./error');
4 4 const coreapi = require('../coreapi');
5 5  
6   -const coreEndpoint = '/stores/view';
7   -
8 6 function help(keyword) {
9   - return `Untuk info sebuah downline, ketik perintah dengan format: ${ keyword.toUpperCase() }.#<IDDOWNLINE>.<PIN>`;
  7 + return `
  8 +Untuk info sebuah downline, ketik perintah dengan format:
  9 +
  10 +${keyword.toUpperCase()}.#<IDDOWNLINE>.<PIN>
  11 +atau
  12 +${keyword.toUpperCase()}.<TERMINALDOWNLINE>.<PIN>
  13 + `.trim();
10 14 }
11 15  
12 16 function execute(tokens, params, cb) {
13   -
  17 +
14 18 if (!tokens || tokens.length < 3) {
15 19 const responseParams = {
16   - body: `${ commandError.ERR_INVALID_FORMAT }. ${ help(tokens[0]) }`
  20 + body: `
  21 +${ commandError.ERR_INVALID_FORMAT }: ${params.msg}
  22 +
  23 +${ help(tokens[0]) }
  24 + `.trim(),
17 25 }
18 26  
19 27 cb(null, null, responseParams);
20 28 return;
21 29 }
22 30  
  31 + let downlineStoreId;
  32 + let downlineTerminalName;
  33 + if (tokens[1].indexOf('#') === 0) {
  34 + downlineStoreId = tokens[1].replace(/^#/, '');
  35 + } else {
  36 + downlineTerminalName = tokens[1];
  37 + }
  38 +
23 39 const coreParams = {
24 40 asker_terminal_name: params.from,
25 41 asker_terminal_password: tokens[2],
26   - downline_store_id: tokens[1].replace(/^#/, ''),
  42 + downline_store_id: downlineStoreId,
  43 + downline_terminal_name: downlineTerminalName,
27 44 };
28 45  
29   - coreapi(coreEndpoint, coreParams, 'GET', cb);
  46 + coreapi(CORE_ENDPOINT, coreParams, 'GET', cb);
30 47 }
31 48  
32 49 module.exports = execute;
33 50 \ No newline at end of file
lib/command-handler/listterminal.js
1   -"use strict";
  1 +const CORE_ENDPOINT = '/terminals';
2 2  
3 3 const commandError = require('./error');
4 4 const coreapi = require('../coreapi');
5 5  
6   -const coreEndpoint = '/terminals';
7   -
8 6 function help(keyword) {
9   - return `Untuk list terminal anda, ketik perintah dengan format: ${ keyword.toUpperCase() }.<PIN> atau ${ keyword.toUpperCase() }.<IDDOWNLINE>.<PIN>`;
  7 + return `
  8 +Untuk list terminal anda, ketik perintah dengan format:
  9 +
  10 +${ keyword.toUpperCase() }.<PIN>
  11 +atau
  12 +${ keyword.toUpperCase() }.#<IDDOWNLINE>.<PIN>
  13 +atau
  14 +${ keyword.toUpperCase() }.<TERMINALDOWNLINE>.<PIN>
  15 + `.trim();
10 16 }
11 17  
12 18 function execute(tokens, params, cb) {
13   -
  19 +
14 20 if (!tokens || tokens.length < 2) {
15 21 const responseParams = {
16   - body: `${ commandError.ERR_INVALID_FORMAT }. ${ help(tokens[0]) }`
  22 + body: `
  23 +${ commandError.ERR_INVALID_FORMAT }: ${params.msg}
  24 +
  25 +${ help(tokens[0]) }
  26 + `.trim(),
17 27 }
18 28  
19 29 cb(null, null, responseParams);
20 30 return;
21 31 }
22 32  
  33 + const idxDownline = (tokens.length <= 2) ? null : 1;
23 34 const idxPin = (tokens.length <= 2) ? 1 : 2;
24 35  
  36 + let downline;
  37 + let downlineStoreId;
  38 + let downlineTerminalName;
  39 + if (idxDownline) {
  40 + downline = tokens[idxDownline];
  41 + if (downline.indexOf('#') === 0) {
  42 + downlineStoreId = downline.replace(/^#/, '');
  43 + } else {
  44 + downlineTerminalName = downline;
  45 + }
  46 + }
  47 +
25 48 const coreParams = {
26 49 asker_terminal_name: params.from,
27 50 asker_terminal_password: tokens[ idxPin ],
28   - store_id: tokens.length > 2 ? tokens[1] : null,
29   -
  51 + store_id: downlineStoreId,
  52 + terminal_name: downlineTerminalName,
30 53 };
31 54  
32   - coreapi(coreEndpoint, coreParams, 'GET', cb);
  55 + coreapi(CORE_ENDPOINT, coreParams, 'GET', cb);
33 56 }
34 57  
35 58 module.exports = execute;
36 59 \ No newline at end of file
lib/command-handler/price.js
1   -"use strict";
  1 +const CORE_ENDPOINT = '/services/pricelist';
2 2  
3 3 const commandError = require('./error');
4 4 const coreapi = require('../coreapi');
5 5  
6   -const coreEndpoint = '/services/pricelist';
7   -
8 6 function help(keyword) {
9 7 return `Untuk cek harga, ketik perintah dengan format: ${ keyword.toUpperCase() }.<KODEPRODUK>.<PIN>`;
10 8 }
... ... @@ -27,7 +25,7 @@ function execute(tokens, params, cb) {
27 25 postpaid: 0
28 26 };
29 27  
30   - coreapi(coreEndpoint, coreParams, 'GET', cb);
  28 + coreapi(CORE_ENDPOINT, coreParams, 'GET', cb);
31 29 }
32 30  
33 31 module.exports = execute;
34 32 \ No newline at end of file
lib/command-handler/transferbalance.js
1   -"use strict";
  1 +const CORE_ENDPOINT = '/stores/transfer-balance';
2 2  
3 3 const commandError = require('./error');
4 4 const coreapi = require('../coreapi');
5 5  
6   -const coreEndpoint = '/stores/transfer-balance';
7   -
8 6 function help(keyword) {
9   - return `Untuk transfer saldo ke downline, ketik perintah dengan format: ${ keyword.toUpperCase() }.<IDDOWNLINE>.<JUMLAH>.<PIN>`;
  7 + return `
  8 +Untuk transfer saldo ke downline, ketik perintah dengan format:
  9 +
  10 +${keyword.toUpperCase()}.#<IDDOWNLINE>.<JUMLAH>.<PIN>
  11 +atau
  12 +${keyword.toUpperCase()}.<TERMINALDOWNLINE>.<JUMLAH>.<PIN>
  13 + `.trim();
10 14 }
11 15  
12 16 function execute(tokens, params, cb) {
13   -
14 17 if (!tokens || tokens.length < 4) {
15 18 const responseParams = {
16   - body: `${ commandError.ERR_INVALID_FORMAT }. ${ help(tokens[0]) }`
  19 + body: `
  20 +${commandError.ERR_INVALID_FORMAT}: ${params.msg}
  21 +
  22 +${ help(tokens[0]) }`.trim(),
17 23 }
18 24  
19 25 cb(null, null, responseParams);
20 26 return;
21 27 }
22 28  
  29 + let destinationStoreId;
  30 + let destinationTerminalName;
  31 + if (tokens[1].indexOf('#') === 0) {
  32 + destinationStoreId = tokens[1].replace(/^#/, '');
  33 + } else {
  34 + destinationTerminalName = tokens[1];
  35 + }
  36 +
23 37 const coreParams = {
24 38 asker_terminal_name: params.from,
25   - destination_store_id: tokens[1],
  39 + destination_store_id: destinationStoreId,
  40 + destination_terminal_name: destinationTerminalName,
26 41 amount: tokens[2],
27 42 asker_terminal_password: tokens[3],
28 43 additional_note: tokens.slice(4).join(' ') || '',
29 44 origin: params.origin
30 45 };
31 46  
32   - coreapi(coreEndpoint, coreParams, 'GET', cb);
  47 + coreapi(CORE_ENDPOINT, coreParams, 'GET', cb);
33 48 }
34 49  
35 50 module.exports = execute;
36 51 \ No newline at end of file
1 1 {
2 2 "name": "komodo-center-messaging",
3   - "version": "0.10.1",
  3 + "version": "0.10.2",
4 4 "lockfileVersion": 1,
5 5 "requires": true,
6 6 "dependencies": {
1 1 {
2 2 "name": "komodo-center-messaging",
3   - "version": "0.10.1",
  3 + "version": "0.10.2",
4 4 "description": "Komodo Common Messaging Center",
5 5 "main": "index.js",
6 6 "scripts": {