"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getChannel = void 0;
const tslib_1 = require("tslib");
const helpers_1 = require("../helpers");
const constants_1 = require("../constants");
const axiosUtil_1 = require("../utils/axiosUtil");
const parseSettings_1 = require("../utils/parseSettings");
const getChannel = (options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
    const { channel, env = constants_1.default.ENV.PROD, raw = true } = options || {};
    const _channel = yield (0, helpers_1.getCAIPAddress)(env, channel, 'Channel');
    const API_BASE_URL = (0, helpers_1.getAPIBaseUrls)(env);
    const apiEndpoint = `${API_BASE_URL}/v1/channels`;
    const requestUrl = `${apiEndpoint}/${_channel}`;
    return yield (0, axiosUtil_1.axiosGet)(requestUrl)
        .then((response) => {
        if (raw)
            return response.data;
        else {
            response.data.channel_settings = response.data.channel_settings ? (0, parseSettings_1.parseSettings)(response.data.channel_settings) : null;
            return response.data;
        }
    })
        .catch((err) => {
        console.error(`[Push SDK] - API ${requestUrl}: `, err);
    });
});
exports.getChannel = getChannel;
//# sourceMappingURL=getChannel.js.map