fedapay-cli
Version:
A command-line tool for FedaPay
75 lines (74 loc) • 2.39 kB
JavaScript
"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 base_1 = tslib_1.__importDefault(require("../../base"));
/**
* EventsRetrieve class extending super class Events
*/
class EventsRetrieve extends base_1.default {
async run() {
/**
* @param object
* get flags value
*/
const { flags } = this.parse(EventsRetrieve);
/**
* @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 string
* Get the id of the event
*/
const id = flags.id || '';
try {
cli_ux_1.default.action.start('Retrieving event');
const event = await fedapay_1.Event.retrieve(id);
this.log(json_colorizer_1.default(JSON.stringify(event, null, 2)));
cli_ux_1.default.action.stop();
}
catch (error) {
this.error(error.message);
}
}
}
exports.default = EventsRetrieve;
/**
* @var string
* Description of the command event:retrieve
*/
EventsRetrieve.description = 'Retrieve an event thanks to its ID';
/**
* The command usage
* @var string
*/
EventsRetrieve.usage = 'events:retrieve [options]';
/**
* @var Object
* Declaration of the command flag
*/
EventsRetrieve.flags = Object.assign(Object.assign({}, base_1.default.flags), { id: command_1.flags.string({
description: 'The Id of the event to retrieve',
}), help: command_1.flags.help({ char: 'h', description: 'Help for events:retrieve command' }) });
/**
* @param String
* Some example with the events:retrieve command
*/
EventsRetrieve.examples = [
'events:retrieve --api-key=[API-KEY] --environment=[env] --id=[ID]',
];