claimbonus.js
1008 Bytes
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
const coreEndpoint = '/rebate/claim-store';
const config = require('komodo-sdk/config');
const commandError = require('./error');
const coreapi = require('../coreapi');
function help(keyword) {
return `Untuk menarik bonus ke saldo, ketik perintah dengan format:\n${keyword.toUpperCase()}.<PIN>`;
}
function execute(tokens, params, cb) {
if (config.disable_claim_bonus || config.disable_claim_rebate) {
const responseParams = {
body: 'Maaf permintaan anda tidak dapat dilakukan',
};
cb(null, null, responseParams);
return;
}
if (!tokens || tokens.length < 2) {
const responseParams = {
body: `${commandError.ERR_INVALID_FORMAT}. ${help(tokens[0])}`,
};
cb(null, null, responseParams);
return;
}
const coreParams = {
asker_terminal_name: params.from,
asker_terminal_password: tokens[1],
};
coreapi(coreEndpoint, coreParams, 'GET', cb);
}
module.exports = execute;