downlineinfo.js
803 Bytes
"use strict";
const commandError = require('./error');
const coreapi = require('../coreapi');
const coreEndpoint = '/stores/view';
function help(keyword) {
return `Untuk info sebuah downline, ketik perintah dengan format: ${ keyword.toUpperCase() }.#<IDDOWNLINE>.<PIN>`;
}
function execute(tokens, params, cb) {
if (!tokens || tokens.length < 3) {
const responseParams = {
body: `${ commandError.ERR_INVALID_FORMAT }. ${ help(tokens[0]) }`
}
cb(null, null, responseParams);
return;
}
const coreParams = {
terminal_name: params.from,
downline_store_id: tokens[1].replace(/^#/, ''),
password: tokens[2],
postpaid: 0
};
coreapi(coreEndpoint, coreParams, 'GET', cb);
}
module.exports = execute;