UNPKG

fedapay-cli

Version:
92 lines (91 loc) 3.04 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 webhooks_1 = tslib_1.__importDefault(require("../webhooks")); const dataparse_1 = tslib_1.__importDefault(require("../../helpers/dataparse")); /** * WebhookList class extending superClass Webhooks */ class WebhooksList extends webhooks_1.default { async run() { /** * @param object * get flags value */ const { flags } = this.parse(WebhooksList); /** * @param String * your api's key */ const apiKey = this.userConfig.read('secret_key', flags['api-key']); /** * @param String * environment or live */ const environment = this.userConfig.read('environment', flags.environment); /** * @param integer * get the limit value */ const limit = flags.limit; /** * @param integer * get the page number value */ 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 webhooks list'); const webhooks = await fedapay_1.Webhook.all(Object.assign({ per_page: limit, page }, filters)); this.log(json_colorizer_1.default(JSON.stringify(webhooks, null, 2))); cli_ux_1.default.action.stop(); } } exports.default = WebhooksList; /** * @params String * Description of the command webhooks:list */ WebhooksList.description = 'List of the webhook records.'; /** * The command usage * @var string */ WebhooksList.usage = 'webhooks:list [options]'; /** * @param object * Declaration of the command flags */ WebhooksList.flags = Object.assign(Object.assign({}, webhooks_1.default.flags), { limit: command_1.flags.integer({ description: 'Limit of records to display.', char: 'l', default: 10, }), page: command_1.flags.integer({ description: 'The page of the records to display.', char: 'p', default: 1 }), filters: command_1.flags.string({ char: 'f', description: 'Filter the list of webhooks.', multiple: true, }), help: command_1.flags.help({ char: 'h', description: 'Help for webhooks:list' }) }); /** * @param Sting[] * Some example of use of the webhook:list command */ WebhooksList.examples = [ 'webhooks:list --api-key=[api_key] --environment=environment --limit=15' ];