UNPKG

fedapay-cli

Version:
91 lines (90 loc) 3.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const command_1 = require("@oclif/command"); const cli_ux_1 = tslib_1.__importDefault(require("cli-ux")); const fedapay_1 = require("fedapay"); const json_colorizer_1 = tslib_1.__importDefault(require("json-colorizer")); const dataparse_1 = tslib_1.__importDefault(require("../../helpers/dataparse")); const base_1 = tslib_1.__importDefault(require("../../base")); /** * EventsList class extending super class Events */ class EventsList extends base_1.default { async run() { /** * @param object * Get flags value */ const { flags } = this.parse(EventsList); /** * @param String * Your API's key */ const apiKey = this.userConfig.read('secret_key', flags['api-key']); /** * @param string * environment type */ const environment = this.userConfig.read('environment', flags.environment); /** * Set Apikey and environment to connect to fedapay */ fedapay_1.FedaPay.setApiKey(apiKey); fedapay_1.FedaPay.setEnvironment(environment); /** * @param integer * Get the limit value */ const limit = flags.limit; /** * @param Object * The filter flag */ const filters = dataparse_1.default.transformFilterForES(flags.filters); try { cli_ux_1.default.action.start('Getting the transactions list'); /** * @var Event, * Result of the filtered listing */ const events = await fedapay_1.Event.all(Object.assign(Object.assign({ per_page: limit }, filters), { match: 'must' })); this.log(json_colorizer_1.default(JSON.stringify(events, null, 2))); cli_ux_1.default.action.stop(); } catch (error) { this.error(error.message); } } } exports.default = EventsList; /** * @var String * Description of the command events:list */ EventsList.description = 'List of the events'; /** * The command usage * @var string */ EventsList.usage = 'events:list [options]'; /** * @param Object * Declaration of the command flags */ EventsList.flags = Object.assign(Object.assign({}, base_1.default.flags), { limit: command_1.flags.integer({ description: 'Limit of the records to display', default: 10, }), filters: command_1.flags.string({ description: 'Filters you want to apply', multiple: true, char: 'f', }), help: command_1.flags.help({ char: 'h', description: 'Help for events:list command' }) }); /** * @param Sting[] * Some example of use of the events:list command */ EventsList.examples = [ 'events:list --api-key=[api_key] --environment=environment --limit=15', 'events:list --api-key=[api_key] --environment=environment --limit=15 -f type=transaction_deleted -f object_id=ID' ];