UNPKG

fedapay-cli

Version:
79 lines (78 loc) 2.55 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 = require("cli-ux"); const customers_1 = tslib_1.__importDefault(require("../customers")); /** * CustomersRetrieve class extending the superClass Customers */ class CustomersRetrieve extends customers_1.default { async run() { /** * Get flags object from CustommersRetrieve * and use them to retrieve an custommer /** * @param object * get flags value */ const { flags } = this.parse(CustomersRetrieve); /** * @param string * api key value */ const apiKey = this.userConfig.read('secret_key', flags['api-key']); /** * @param string * environment type */ const environment = this.userConfig.read('environment', flags.environment); /** * @param number * store the customer id */ const id = flags.id; /** * Set Apikey and environment to connect to fedapay */ fedapay_1.FedaPay.setApiKey(apiKey); fedapay_1.FedaPay.setEnvironment(environment); try { cli_ux_1.cli.action.start('Retrieve customer'); const customer = await fedapay_1.Customer.retrieve(id); this.log(json_colorizer_1.default(JSON.stringify(customer, null, 2))); } catch (error) { this.error(error.message); } cli_ux_1.cli.action.stop(); } } exports.default = CustomersRetrieve; /** * @param string * Description of the command Customer:retrieve */ CustomersRetrieve.description = 'Retrieve a customer.'; /** * @param object * Declaration of the command flags */ CustomersRetrieve.flags = Object.assign(Object.assign({}, customers_1.default.flags), { id: command_1.flags.integer({ description: 'ID of the customer.', required: true, }), help: command_1.flags.help({ char: 'h', description: 'Help for customers:retrieve command.' }) }); /** * @param string * Set the command usage for help */ CustomersRetrieve.usage = 'customers:retrieve [options]'; /** * @param string[] * some examples of the custommers retrieve use for help */ CustomersRetrieve.examples = [ 'customers:retrieve --api-key=[API-KEY] --environment=[env] --id=5' ];