"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSdkClient = void 0;
const lib_1 = require("twilio/lib");
const extensions_core_1 = require("@awell-health/extensions-core");
const zod_1 = __importDefault(require("zod"));
const settings_1 = require("../settings");
const twilio_1 = __importDefault(require("./sdk/twilio"));
const createSdkClient = async ({ payload, skipRegion = false, }) => {
    const { settings: { accountSid, authToken, clientId, region }, } = (0, extensions_core_1.validate)({
        schema: zod_1.default.object({
            settings: settings_1.SettingsValidationSchema,
        }),
        payload,
    });
    // skip region also means that we don't need to pass the accountSid
    const options = skipRegion ? {} : { accountSid, region: region !== null && region !== void 0 ? region : 'IE1' };
    if (clientId !== undefined) {
        const client = new lib_1.Twilio(clientId, authToken, options);
        return { client };
    }
    else {
        const client = (0, twilio_1.default)(accountSid, authToken, options);
        return { client };
    }
};
exports.createSdkClient = createSdkClient;
//# sourceMappingURL=createSdkClient.js.map