"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 trackEvent_1 = __importDefault(require("./trackEvent"));
const identify_1 = __importDefault(require("./identify"));
const destination = {
    name: 'Drip (Actions)',
    slug: 'actions-drip',
    mode: 'cloud',
    description: 'Send Segment analytics events and user profile details to Drip',
    authentication: {
        scheme: 'custom',
        fields: {
            accountId: {
                label: 'Account ID',
                description: 'Account ID for your Drip account. You can find this in your Drip account settings.',
                type: 'string',
                required: true
            },
            apiKey: {
                label: 'API Key',
                description: 'API key for your Drip account. You can find this in your Drip account settings.',
                type: 'password',
                required: true
            }
        },
        testAuthentication: (request) => {
            return request(`https://api.getdrip.com/v2/user`, {
                method: 'get'
            });
        }
    },
    presets: [
        {
            name: 'Identify',
            subscribe: 'type = "identify"',
            partnerAction: 'identify',
            mapping: (0, actions_core_1.defaultValues)(identify_1.default.fields),
            type: 'automatic'
        },
        {
            name: 'Track event',
            subscribe: 'type = "track"',
            partnerAction: 'trackEvent',
            mapping: (0, actions_core_1.defaultValues)(trackEvent_1.default.fields),
            type: 'automatic'
        }
    ],
    extendRequest({ settings }) {
        return {
            headers: {
                'Content-Type': 'application/json',
                Authorization: `Basic ${settings.apiKey}`,
                'User-Agent': 'Segment (Actions)'
            }
        };
    },
    actions: {
        trackEvent: trackEvent_1.default,
        identify: identify_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map