listdeposit.js
1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const config = require('komodo-sdk/config');
const coreEndpoint = '/histories/mutations/deposit-and-transfer';
const commandError = require('./error');
const coreapi = require('../coreapi');
function help(keyword) {
return `
Format perintah utk list deposit dan transfer:
${keyword.toUpperCase()}.<PIN> atau ${keyword.toUpperCase()}.<TANGGAL>.<PIN>.
<TANGGAL> dlm format YYYY-MM-DD, contoh 2018-12-31 untuk tanggal 31 Desember 2018.
`.trim();
}
function execute(tokens, params, cb) {
if (!tokens || tokens.length < 2) {
const responseParams = {
body: `${commandError.ERR_INVALID_FORMAT}. ${help(tokens[0])}`,
};
cb(null, null, responseParams);
return;
}
const idxPin = tokens.length < 3 ? 1 : 2;
const coreParams = {
origin: params.origin,
asker_terminal_name: params.from,
asker_terminal_password: tokens[idxPin],
created_date: tokens.length < 3 ? null : tokens[1],
ascending: (config.ascending_mutation || config.ascending_deposit) ? 'true' : 'false',
};
coreapi(coreEndpoint, coreParams, 'GET', cb);
}
module.exports = execute;