Commit 558708432aa9461bd16ae6121b95503348c86650

Authored by Adhidarma Hadiwinoto
1 parent 7792c4ae0d
Exists in master

Some eslint

Showing 2 changed files with 13 additions and 16 deletions Inline Diff

lib/command-handler/daysummary.js
1 "use strict";
2
3 const coreEndpoint = '/stores/summary'; 1 const coreEndpoint = '/stores/summary';
4 2
5 const commandError = require('./error'); 3 const commandError = require('./error');
6 const coreapi = require('../coreapi'); 4 const coreapi = require('../coreapi');
7 5
8 function help(keyword) { 6 function help(keyword) {
9 return `Untuk melihat laporan harian, ketik perintah dengan format: ${ keyword.toUpperCase() }.<PIN> atau ${ keyword.toUpperCase() }.<TANGGAL>.<PIN>. Format tanggal YYYY-MM-DD, contoh 2018-12-31 untuk tanggal 31 Desember 2018.`; 7 return `Untuk melihat laporan harian, ketik perintah dengan format: ${keyword.toUpperCase()}.<PIN> atau ${keyword.toUpperCase()}.<TANGGAL>.<PIN>. Format tanggal YYYY-MM-DD, contoh 2018-12-31 untuk tanggal 31 Desember 2018.`;
10 } 8 }
11 9
12 function execute(tokens, params, cb) { 10 function execute(tokens, params, cb) {
13
14 if (!tokens || tokens.length < 2) { 11 if (!tokens || tokens.length < 2) {
15 const responseParams = { 12 const responseParams = {
16 body: `${ commandError.ERR_INVALID_FORMAT }. ${ help(tokens[0]) }` 13 body: `${commandError.ERR_INVALID_FORMAT}. ${help(tokens[0])}`,
17 } 14 };
18 15
19 cb(null, null, responseParams); 16 cb(null, null, responseParams);
20 return; 17 return;
21 } 18 }
22 19
23 const idxPin = tokens.length < 3 ? 1 : 2; 20 const idxPin = tokens.length < 3 ? 1 : 2;
24 21
25 const coreParams = { 22 const coreParams = {
26 origin: params.origin, 23 origin: params.origin,
27 asker_terminal_name: params.from, 24 asker_terminal_name: params.from,
28 asker_terminal_password: tokens[idxPin], 25 asker_terminal_password: tokens[idxPin],
29 created_date: tokens.length < 3 ? null : tokens[1], 26 created_date: tokens.length < 3 ? null : tokens[1],
30 include_downline: params.commandGroup === 'daysummaryall', 27 include_downline: params.commandGroup === 'daysummaryall',
31 }; 28 };
32 29
33 coreapi(coreEndpoint, coreParams, 'GET', cb); 30 coreapi(coreEndpoint, coreParams, 'GET', cb);
34 } 31 }
35 32
36 module.exports = execute;
lib/command-handler/listtrx.js
1 const coreEndpoint = '/histories/trx'; 1 const coreEndpoint = '/histories/trx';
2 2
3 const config = require('komodo-sdk/config'); 3 const config = require('komodo-sdk/config');
4 4
5 const commandError = require('./error'); 5 const commandError = require('./error');
6 const coreapi = require('../coreapi'); 6 const coreapi = require('../coreapi');
7 7
8 function help(keyword, commandGroup) { 8 function help(keyword, commandGroup) {
9 return `Untuk melihat list transaksi${ commandGroup === 'listtrxall' ? ' termasuk downline': ''}, ketik perintah dengan format: ${ keyword.toUpperCase() }.<PIN> atau ${ keyword.toUpperCase() }.<TANGGAL>.<PIN>. Format tanggal YYYY-MM-DD, contoh 2018-12-31 untuk tanggal 31 Desember 2018.`; 9 return `Untuk melihat list transaksi${
10 commandGroup === 'listtrxall'
11 ? ' termasuk downline'
12 : ''
13 }, ketik perintah dengan format: ${keyword.toUpperCase()}.<PIN> atau ${keyword.toUpperCase()}.<TANGGAL>.<PIN>. Format tanggal YYYY-MM-DD, contoh 2018-12-31 untuk tanggal 31 Desember 2018.`;
10 } 14 }
11 15
12 module.exports = (tokens, params, cb) => { 16 module.exports = (tokens, params, cb) => {
13 if (params.commandGroup === 'listtrxall') { 17 if (params.commandGroup === 'listtrxall') {
14 const blacklisted = ((config.blacklist_help_for_origins || []).indexOf(params.origin || '') >= 0) 18 const blacklisted = ((config.blacklist_help_for_origins || []).indexOf(params.origin || '') >= 0)
15 || ((config.blacklist_help_for_origin_transports || []).indexOf(params.origin_transport || '') >= 0); 19 || ((config.blacklist_help_for_origin_transports || []).indexOf(params.origin_transport || '') >= 0);
16 20
17 if (blacklisted) { 21 if (blacklisted) {
18 const body = `Perintah "${tokens[0]}" tdk tersedia pd jalur SMS dan sejenis.`; 22 const body = `Perintah "${tokens[0]}" tdk tersedia pd jalur SMS dan sejenis.`;
19 const responseParams = { 23 const responseParams = { body };
20 body 24
21 }
22
23 cb(null, null, responseParams); 25 cb(null, null, responseParams);
24 return; 26 return;
25 } 27 }
26 } 28 }
27
28
29 29
30 if (!tokens || tokens.length < 2) { 30 if (!tokens || tokens.length < 2) {
31 const responseParams = { 31 const responseParams = {
32 body: `${ commandError.ERR_INVALID_FORMAT }. ${ help(tokens[0], params.commandGroup) }` 32 body: `${commandError.ERR_INVALID_FORMAT}. ${help(tokens[0], params.commandGroup)}`,
33 } 33 };
34 34
35 cb(null, null, responseParams); 35 cb(null, null, responseParams);
36 return; 36 return;
37 } 37 }
38 38
39 const idxPin = tokens.length < 3 ? 1 : 2; 39 const idxPin = tokens.length < 3 ? 1 : 2;
40 40
41 const coreParams = { 41 const coreParams = {
42 origin: params.origin, 42 origin: params.origin,
43 asker_terminal_name: params.from, 43 asker_terminal_name: params.from,
44 asker_terminal_password: tokens[idxPin], 44 asker_terminal_password: tokens[idxPin],
45 date: tokens.length < 3 ? null : tokens[1], 45 date: tokens.length < 3 ? null : tokens[1],
46 include_downlines: params.commandGroup === 'listtrxall', 46 include_downlines: params.commandGroup === 'listtrxall',
47 dont_include_failed: true, 47 dont_include_failed: true,
48 limit: 100, 48 limit: 100,
49 offset: 0, 49 offset: 0,
50 order: 'DESC', 50 order: 'DESC',
51 }; 51 };