polyv-live-cli
Version:
CLI tool for managing PolyV live streaming services.
59 lines • 2.48 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TransmitServiceSdk = void 0;
const polyv_live_api_sdk_1 = require("polyv-live-api-sdk");
class TransmitServiceSdk {
constructor(authConfig, config) {
this.client = new polyv_live_api_sdk_1.PolyVClient({
appId: authConfig.appId,
appSecret: authConfig.appSecret,
baseUrl: config?.baseUrl || 'https://api.polyv.net',
});
this.channel = this.client.channel;
}
async batchCreateTransmitChannels(channelId, names) {
if (!channelId || channelId.trim() === '') {
throw new Error('Channel ID is required (频道ID是必需的)');
}
if (!names || names.length === 0) {
throw new Error('Names are required (频道名称是必需的)');
}
if (names.length > 100) {
throw new Error('Names count exceeds maximum of 100 (频道名称数量超过最大值100)');
}
const result = await this.channel.batchAddTransmit({ channelId, names });
return this.unwrapData(result) || [];
}
async getTransmitAssociations(channelId) {
if (!channelId || channelId.trim() === '') {
throw new Error('Channel ID is required (频道ID是必需的)');
}
const result = await this.channel.getTransmitAssociations({ channelId });
return this.unwrapData(result) || [];
}
async associationReceiveChannels(options) {
if (!options.channelId || options.channelId.trim() === '') {
throw new Error('Channel ID is required (频道ID是必需的)');
}
if (!options.receiveChannelIds || options.receiveChannelIds.length === 0) {
throw new Error('Receive channel IDs are required (接收频道ID是必需的)');
}
const associationOptions = {
channelId: options.channelId,
receiveChannelIds: options.receiveChannelIds,
};
if (options.type) {
associationOptions.type = options.type;
}
const result = await this.channel.associationReceiveChannels(associationOptions);
return this.unwrapData(result) || [];
}
unwrapData(value) {
if (value && typeof value === 'object' && 'data' in value) {
return value.data;
}
return value;
}
}
exports.TransmitServiceSdk = TransmitServiceSdk;
//# sourceMappingURL=transmit-service.js.map