"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CLAY_API_BASE_URL = void 0;
const actions_core_1 = require("@segment/actions-core");
const pageVisit_1 = __importDefault(require("./pageVisit"));
const track_1 = __importDefault(require("./track"));
exports.CLAY_API_BASE_URL = 'https://segment-session.clay.com';
const presets = [
    {
        name: 'Page Visit',
        subscribe: 'type = "page"',
        partnerAction: 'pageVisit',
        mapping: (0, actions_core_1.defaultValues)(pageVisit_1.default.fields),
        type: 'automatic'
    },
    {
        name: 'Track Calls',
        subscribe: 'type = "track"',
        partnerAction: 'track',
        mapping: (0, actions_core_1.defaultValues)(track_1.default.fields),
        type: 'automatic'
    }
];
const destination = {
    name: 'Clay',
    slug: 'actions-clay',
    mode: 'cloud',
    authentication: {
        scheme: 'custom',
        fields: {
            connection_key: {
                label: 'Connection Key',
                description: 'Your Clay connection key',
                type: 'password',
                required: true
            },
            secret_key: {
                label: 'Secret Key',
                description: 'Your Clay secret key',
                type: 'password',
                required: true
            }
        },
        testAuthentication: (request, { settings }) => {
            return request(`${exports.CLAY_API_BASE_URL}/segment/${settings.connection_key}/auth`, {
                method: 'GET',
                headers: {
                    Authorization: `Bearer ${settings.secret_key}`
                }
            });
        }
    },
    presets,
    actions: {
        pageVisit: pageVisit_1.default,
        track: track_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map