polyv-live-cli
Version:
CLI tool for managing PolyV live streaming services.
58 lines • 3.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FinanceHandler = void 0;
const base_handler_1 = require("./base.handler");
const errors_1 = require("../utils/errors");
const api_command_1 = require("../utils/api-command");
const finance_service_1 = require("../services/finance-service");
class FinanceHandler extends base_handler_1.BaseHandler {
constructor(authConfig, serviceConfig) {
super();
this.service = new finance_service_1.FinanceServiceSdk(authConfig, serviceConfig);
}
async getAudioSettings(options) {
this.requireFields(options, ['channelId']);
this.show(await this.service.getAudioModerationSettings(options.channelId), options.output);
}
async listAudioRecords(options) {
this.requireFields(options, ['channelId']);
this.show(await this.service.listAudioModerationRecords(options.channelId, (0, api_command_1.apiParams)({ ...options, channelId: undefined })), options.output);
}
async updateAudioSettings(options) {
this.requireFields(options, ['channelId']);
const params = (0, api_command_1.apiParams)({ ...options, channelId: undefined });
await (0, api_command_1.confirmWrite)(options.force, `Update audio moderation settings for channel ${options.channelId}?`);
await this.service.updateAudioModerationSettings(options.channelId, params);
this.show({ success: true, channelId: options.channelId, ...params }, options.output);
}
async getVideoSettings(options) {
this.requireFields(options, ['channelId']);
this.show(await this.service.getVideoModerationSettings(options.channelId), options.output);
}
async updateVideoSettings(options) {
this.requireFields(options, ['channelId']);
const params = (0, api_command_1.apiParams)({ ...options, channelId: undefined });
await (0, api_command_1.confirmWrite)(options.force, `Update video moderation settings for channel ${options.channelId}?`);
await this.service.updateVideoModerationSettings(options.channelId, params);
this.show({ success: true, channelId: options.channelId, ...params }, options.output);
}
async listVideoResults(options) {
this.requireFields(options, ['channelId']);
this.show(await this.service.listVideoModerationResults(options.channelId, (0, api_command_1.apiParams)({ ...options, channelId: undefined })), options.output);
}
async listBillDetails(options) {
this.requireFields(options, ['itemCategory', 'startDate', 'endDate']);
this.show(await this.service.listBillDetails((0, api_command_1.apiParams)(options)), options.output);
}
show(data, output = 'table') {
this.displayData(data, output);
}
requireFields(options, fields) {
const missing = fields.filter((field) => options[field] === undefined || options[field] === '');
if (missing.length > 0) {
throw new errors_1.PolyVValidationError(`Missing required option(s): ${missing.join(', ')}`, 'options', options, 'validation_failed');
}
}
}
exports.FinanceHandler = FinanceHandler;
//# sourceMappingURL=finance.handler.js.map