"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getChannels = void 0;
const tslib_1 = require("tslib");
const constantsV2_1 = require("../constantsV2");
const helpers_1 = require("../helpers");
const axiosUtil_1 = require("../utils/axiosUtil");
const getChannels = (options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
    const { env = constantsV2_1.default.ENV.PROD, page = 1, limit = 10, sort = constantsV2_1.default.FILTER.CHANNEL_LIST.SORT.SUBSCRIBER, order = constantsV2_1.default.FILTER.CHANNEL_LIST.ORDER.DESCENDING, filter, tag, } = options || {};
    const API_BASE_URL = (0, helpers_1.getAPIBaseUrls)(env);
    const apiEndpoint = `${API_BASE_URL}/v1/channels`;
    const requestUrl = `${apiEndpoint}?page=${page}&limit=${limit}&sort=${sort}&order=${order}${filter ? '&filter=' + filter : ''}${tag ? '&tag=' + tag : ''}`;
    return yield (0, axiosUtil_1.axiosGet)(requestUrl)
        .then((response) => {
        return response.data;
    })
        .catch((err) => {
        console.error(`[Push SDK] - API ${requestUrl}: `, err);
        throw Error(`[Push SDK] - API  - Error - API ${requestUrl} -: ${err}`);
    });
});
exports.getChannels = getChannels;
//# sourceMappingURL=getChannels.js.map