UNPKG

fedapay-cli

Version:
86 lines (85 loc) 2.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const command_1 = require("@oclif/command"); const fedapay_1 = require("fedapay"); const payouts_1 = tslib_1.__importDefault(require("../payouts")); const cli_ux_1 = tslib_1.__importDefault(require("cli-ux")); /** * PayoutsSendNow class */ class PayoutsSendNow extends payouts_1.default { async run() { /** * Get flags object from CustommersList * and use them to retrieve and list the custommers */ /** * @param object * get flags value */ const { flags } = this.parse(PayoutsSendNow); /** * @param string * api key value */ const apiKey = this.userConfig.read('secret_key', flags['api-key']); /** * @param String * sandbox or live */ const environment = this.userConfig.read('environment', flags.environment); /** * @param number * The payout ID */ const ids = flags.id.map(i => { return { id: i }; }); fedapay_1.FedaPay.setApiKey(apiKey); fedapay_1.FedaPay.setEnvironment(environment); try { /** * @param string * the input data sent is a string * transform data in array of object * @param {Object} */ cli_ux_1.default.action.start('Sending the payouts'); await fedapay_1.Payout.sendAllNow(ids); } catch (error) { this.error(error.message); } cli_ux_1.default.action.stop(); } } exports.default = PayoutsSendNow; /** * @param string * Description of the payouts:schedule command */ PayoutsSendNow.description = 'Send payouts.'; PayoutsSendNow.flags = Object.assign(Object.assign({}, payouts_1.default.flags), { /** *@param object * provide data passing flags */ id: command_1.flags.string({ description: 'The payouts id.', multiple: true, required: true }), help: command_1.flags.help({ char: 'h', description: 'Help for payouts:send-now.' }) }); /** * @param string * Set the command usage for help */ PayoutsSendNow.usage = 'payouts:send-now [options]'; /** * @param string[] * examples of send-now command for the help */ PayoutsSendNow.examples = [ 'payouts:send-now --id=105', 'payouts:send-now --id=105 --id=108"' ];