fedapay-cli
Version:
A command-line tool for FedaPay
75 lines (74 loc) • 2.35 kB
JavaScript
"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 webhooks_1 = tslib_1.__importDefault(require("../webhooks"));
/**
* WebhookRetrieve class extending super Class Webhooks
*/
class WebhooksRetrieve extends webhooks_1.default {
async run() {
/**
* @param object
* get flags value
*/
const { flags } = this.parse(WebhooksRetrieve);
/**
* @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 id of the webhook
*/
const id = flags.id;
try {
cli_ux_1.cli.action.start('Retrieve webhook');
const webhook = await fedapay_1.Webhook.retrieve(id);
this.log(json_colorizer_1.default(JSON.stringify(webhook, null, 2)));
}
catch (error) {
this.error(error.message);
}
}
}
exports.default = WebhooksRetrieve;
/**
* @params String
* Description of the command webhooks:retrieve
*/
WebhooksRetrieve.description = 'Retrieve a webhook.';
/**
* The command usage
* @var string
*/
WebhooksRetrieve.usage = 'webhooks:retrieve [options]';
/**
* @param object
* Declaration of the command flags
*/
WebhooksRetrieve.flags = Object.assign(Object.assign({}, webhooks_1.default.flags), { id: command_1.flags.integer({
required: true,
description: 'ID of the webhook.'
}), help: command_1.flags.help({ char: 'h', description: 'Help for webhooks:retrieve command.' }) });
/**
* @param String
* Some example with the retrieve command
*/
WebhooksRetrieve.examples = [
'webhooks:retrieve --api-key=[API-KEY] --environment=[env] --id=[ID]'
];