"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const actions_core_1 = require("@segment/actions-core");
const sendContact_1 = __importDefault(require("./sendContact"));
const sendCustomer_1 = __importDefault(require("./sendCustomer"));
const destination = {
    name: 'ChartMogul',
    slug: 'actions-chartmogul',
    mode: 'cloud',
    description: 'Send Contacts and Customers to ChartMogul.',
    authentication: {
        scheme: 'custom',
        fields: {
            chartmogul_webhook_url: {
                label: 'ChartMogul webhook URL',
                description: 'Copy the webhook URL from ChartMogul and paste it here',
                type: 'string',
                format: 'uri',
                required: true
            }
        },
        testAuthentication: (request, auth) => {
            const targetUrl = auth?.settings?.chartmogul_webhook_url;
            if (!targetUrl || !targetUrl.startsWith('https://')) {
                throw new actions_core_1.InvalidAuthenticationError('Please configure the ChartMogul webhook URL.');
            }
            return request(targetUrl, {
                method: 'post',
                json: {}
            });
        }
    },
    actions: {
        sendContact: sendContact_1.default,
        sendCustomer: sendCustomer_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map