UNPKG

fedapay-cli

Version:
91 lines (90 loc) 3.13 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 cli_ux_1 = tslib_1.__importDefault(require("cli-ux")); const json_colorizer_1 = tslib_1.__importDefault(require("json-colorizer")); const payouts_1 = tslib_1.__importDefault(require("../payouts")); const dataparse_1 = tslib_1.__importDefault(require("../../helpers/dataparse")); /** * PayoutsUpdate class */ class PayoutsUpdate extends payouts_1.default { async run() { /** * @param object * get flags value */ const { flags } = this.parse(PayoutsUpdate); /** * @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 * store the customer id */ const id = flags.id; /** * @param object * result of transforming flags.data into Typescript Object */ const data = dataparse_1.default.transform(flags.data); /** * Set Apikey and environment to connect to fedapay */ fedapay_1.FedaPay.setApiKey(apiKey); fedapay_1.FedaPay.setEnvironment(environment); try { /** * @param object */ cli_ux_1.default.action.start('Updating payout'); const payout = fedapay_1.Payout.update(id, data); this.log(json_colorizer_1.default(JSON.stringify(payout, null, 2))); } catch (error) { this.error(error.message); } cli_ux_1.default.action.stop(); } } exports.default = PayoutsUpdate; /** * @param string * Description of the command Custommers:update description */ PayoutsUpdate.description = 'Update a payout.'; /** * @param object * Declaration of the command flags */ PayoutsUpdate.flags = Object.assign(Object.assign({}, payouts_1.default.flags), { id: command_1.flags.integer({ description: 'The pauyout ID.', required: true }), data: command_1.flags.string({ description: 'Data for the API request.', required: true, char: 'd', multiple: true, }), help: command_1.flags.help({ char: 'h', description: 'Help for payouts:update command.' }) }); /** * @param string * Set the command usage for help */ PayoutsUpdate.usage = 'payouts:update [options]'; /** * @param string[] * examples command for the help */ PayoutsUpdate.examples = [ 'payouts:update --api-key=[API-KEY] --environment=[env] --id=90 -d amount=550 -d currency[iso]=XOF -d mode=moov -d customer[firstname]=Yu customer[lastname]=Ma customer[email]=vul@exemple.com customer[phone_number][number]=65423158 customer[phone_number][country]=bj', 'payouts:update --api-key=[API-KEY] --environment=[env] --id=109 -d customer[id]=2055', ];