"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDomain = void 0;
const postToCourier_1 = __importDefault(require("./postToCourier"));
const audienceToList_1 = __importDefault(require("./audienceToList"));
const destination = {
    name: 'Courier (Actions)',
    slug: 'actions-courier',
    mode: 'cloud',
    authentication: {
        scheme: 'custom',
        fields: {
            apiKey: {
                label: 'API Key',
                description: 'Courier API Key from Segment integration page in the Courier Designer.',
                type: 'password',
                required: true
            },
            region: {
                label: 'Region',
                description: 'Courier Region (US or EU)',
                type: 'string',
                default: 'US',
                choices: [
                    {
                        value: 'US',
                        label: 'US'
                    },
                    {
                        value: 'EU',
                        label: 'EU'
                    }
                ],
                required: true
            }
        },
        testAuthentication: (request, { settings }) => {
            const domain = (0, exports.getDomain)(settings.region);
            return request(`${domain}/debug`, { method: 'POST', headers: { Authorization: `Bearer ${settings.apiKey}` } });
        }
    },
    actions: {
        postToCourier: postToCourier_1.default,
        audienceToList: audienceToList_1.default
    },
    extendRequest({ settings }) {
        return {
            headers: {
                Authorization: `Bearer ${settings.apiKey}`,
                'Content-Type': 'application/json',
                'User-Agent': 'SegmentCourier'
            }
        };
    }
};
const getDomain = (region) => `https://api.${region === 'EU' ? 'eu.' : ''}courier.com`;
exports.getDomain = getDomain;
exports.default = destination;
//# sourceMappingURL=index.js.map