UNPKG

fedapay-cli

Version:
93 lines (92 loc) 3.16 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 json_colorizer_1 = tslib_1.__importDefault(require("json-colorizer")); const cli_ux_1 = tslib_1.__importDefault(require("cli-ux")); const payouts_1 = tslib_1.__importDefault(require("../payouts")); const dataparse_1 = tslib_1.__importDefault(require("../../helpers/dataparse")); /** * PayoutsList commnd class */ class PayoutsList 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(PayoutsList); /** * @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 number of customers to display */ const limit = flags.limit; /** * @param number * store the number of the page to display */ const page = flags.page; /** * @param Object * The filter flag * TODO: Use filter for the list */ const filters = dataparse_1.default.transformFilters(flags.filters); /** * Set Apikey and environment to connect to fedapay */ fedapay_1.FedaPay.setApiKey(apiKey); fedapay_1.FedaPay.setEnvironment(environment); cli_ux_1.default.action.start('Getting the payouts list'); const payouts = await fedapay_1.Payout.all(Object.assign({ per_page: limit, page: page }, filters)); this.log(json_colorizer_1.default(JSON.stringify(payouts, null, 2))); cli_ux_1.default.action.stop(); } } exports.default = PayoutsList; /** * @param string * Description of payouts:delete command */ PayoutsList.description = 'List of the payout records.'; /** * @param object * Declaration of the command flags */ PayoutsList.flags = Object.assign(Object.assign({}, payouts_1.default.flags), { limit: command_1.flags.integer({ char: 'l', description: 'Limit of records to display.', default: 10, }), filters: command_1.flags.string({ char: 'f', description: 'Filter the list of payouts.', multiple: true, }), page: command_1.flags.integer({ description: 'The page of the records to display.', char: 'p', default: 1 }), help: command_1.flags.help({ char: 'h', description: 'Help for payouts:list' }) }); /** * @param string * Set the command usage for help */ PayoutsList.usage = 'payouts:list [options]'; PayoutsList.examples = [ 'payouts:list --api-key=[API-KEY] --environment=[env] --limit=20', 'payouts:list --api-key=[API-KEY] --environment=[env] --page=2', ];