UNPKG

fedapay-cli

Version:
88 lines (87 loc) 2.75 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 = require("cli-ux"); const chalk = require("chalk"); /** * PayoutsSchedule class */ class PayoutsSchedule 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(PayoutsSchedule); /** * @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 id = flags.id; /** * @param string * The schedule date */ const when = flags.when; fedapay_1.FedaPay.setApiKey(apiKey); fedapay_1.FedaPay.setEnvironment(environment); try { cli_ux_1.cli.action.start('Retrieving payout'); const payout = await fedapay_1.Payout.retrieve(id); cli_ux_1.cli.action.start('Scheduling payout'); payout.schedule(when); this.log(chalk.green(`Payout schedule for ${when}`)); } catch (error) { this.error(error.message); } cli_ux_1.cli.action.stop(); } } exports.default = PayoutsSchedule; /** * @param string * Description of the payouts:schedule command */ PayoutsSchedule.description = 'Schedule a payout to be sent later.'; /** * @param object * Declaration of the command flags */ PayoutsSchedule.flags = Object.assign(Object.assign({}, payouts_1.default.flags), { id: command_1.flags.integer({ description: 'The id of the payout to schedule', required: true, }), when: command_1.flags.string({ description: 'The DateTime of the schedule in the format YYYY-MM-DD HH:mm:ss GMT', required: true, char: 'w' }), help: command_1.flags.help({ char: 'h', description: 'Help for payouts:schedule' }) }); /** * @param string * Set the command usage for help */ PayoutsSchedule.usage = 'payouts:schedule [options]'; /** * @param string[] * schedule payouts command */ PayoutsSchedule.examples = [ 'payouts:schedule --api-key=[API-KEY] --environment=[env] --id=[ID] --when="2020-8-12 11:41:51"', ];