@apillon/sdk
Version:
▶◀ Apillon SDK for NodeJS ▶◀
68 lines • 2.74 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Social = void 0;
const apillon_1 = require("../../lib/apillon");
const apillon_api_1 = require("../../lib/apillon-api");
const common_1 = require("../../lib/common");
const social_channel_1 = require("./social-channel");
const social_hub_1 = require("./social-hub");
class Social extends apillon_1.ApillonModule {
constructor() {
super(...arguments);
this.HUBS_API_PREFIX = '/social/hubs';
this.CHANNELS_API_PREFIX = '/social/channels';
}
/**
* Lists all hubs with optional filters.
* @param {IApillonPagination} params Optional filters for listing hubs.
* @returns A list of Hub instances.
*/
async listHubs(params) {
const data = await apillon_api_1.ApillonApi.get((0, common_1.constructUrlWithQueryParams)(this.HUBS_API_PREFIX, params));
return Object.assign(Object.assign({}, data), { items: data.items.map((hub) => new social_hub_1.SocialHub(hub.hubUuid, hub)) });
}
/**
* Lists all channels with optional filters.
* @param {IChannelFilters} params Optional filters for listing channels.
* @returns A list of Channel instances.
*/
async listChannels(params) {
const url = (0, common_1.constructUrlWithQueryParams)(this.CHANNELS_API_PREFIX, params);
const data = await apillon_api_1.ApillonApi.get(url);
return Object.assign(Object.assign({}, data), { items: data.items.map((channel) => new social_channel_1.SocialChannel(channel.channelUuid, channel)) });
}
/**
* Creates a new hub.
* @param {ICreateHub} hubData Data for creating the hub.
* @returns The created Hub instance.
*/
async createHub(hubData) {
const hub = await apillon_api_1.ApillonApi.post(this.HUBS_API_PREFIX, hubData);
return new social_hub_1.SocialHub(hub.hubUuid, hub);
}
/**
* Creates a new channel.
* @param {ICreateChannel} channelData Data for creating the channel.
* @returns The created Channel instance.
*/
async createChannel(channelData) {
const channel = await apillon_api_1.ApillonApi.post(this.CHANNELS_API_PREFIX, channelData);
return new social_channel_1.SocialChannel(channel.channelUuid, channel);
}
/**
* @param uuid Unique hub identifier.
* @returns An empty instance of SocialHub.
*/
hub(uuid) {
return new social_hub_1.SocialHub(uuid);
}
/**
* @param uuid Unique channel identifier.
* @returns An empty instance of SocialChannel.
*/
channel(uuid) {
return new social_channel_1.SocialChannel(uuid);
}
}
exports.Social = Social;
//# sourceMappingURL=social.js.map