"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 utils_1 = require("./utils");
const deleteUser_1 = require("./deleteUser");
const trackEvent_1 = __importDefault(require("./trackEvent"));
const identifyUser_1 = __importDefault(require("./identifyUser"));
const trackPageView_1 = __importDefault(require("./trackPageView"));
const aliasUser_1 = __importDefault(require("./aliasUser"));
const createUpdateObject_1 = __importDefault(require("./createUpdateObject"));
const addTag_1 = __importDefault(require("./addTag"));
const removeTag_1 = __importDefault(require("./removeTag"));
const destination = {
    name: 'Encharge (Actions)',
    slug: 'encharge-cloud-actions',
    mode: 'cloud',
    authentication: {
        scheme: 'custom',
        fields: {
            apiKey: {
                description: 'Encharge.io API Key. This can be found on your [Account page](https://app.encharge.io/settings/api-keys).',
                label: 'API Key',
                type: 'password',
                required: true
            }
        },
        testAuthentication: (request) => {
            return request(`${utils_1.enchargeRestAPIBase}/v1/accounts/info`);
        }
    },
    extendRequest: ({ settings }) => {
        return {
            headers: {
                'X-Encharge-Token': settings.apiKey,
                'Content-Type': 'application/json',
                'X-Segment-Actions': '1'
            }
        };
    },
    onDelete: deleteUser_1.deleteUser,
    description: 'Encharge is a marketing automation platform that enables B2B SaaS companies to automate their marketing processes to increase customer engagement, retention, and revenue.',
    presets: [
        {
            partnerAction: 'trackEvent',
            name: 'Track Event',
            subscribe: 'type = "track"',
            mapping: (0, actions_core_1.defaultValues)(trackEvent_1.default.fields),
            type: 'automatic'
        },
        {
            partnerAction: 'identifyUser',
            name: 'Identify User',
            subscribe: 'type = "identify"',
            mapping: (0, actions_core_1.defaultValues)(identifyUser_1.default.fields),
            type: 'automatic'
        },
        {
            partnerAction: 'trackPageView',
            name: 'Track Page View',
            subscribe: 'type = "page"',
            mapping: (0, actions_core_1.defaultValues)(trackPageView_1.default.fields),
            type: 'automatic'
        },
        {
            partnerAction: 'aliasUser',
            name: 'Alias User',
            subscribe: 'type = "alias"',
            mapping: (0, actions_core_1.defaultValues)(aliasUser_1.default.fields),
            type: 'automatic'
        },
        {
            partnerAction: 'createUpdateObject',
            name: 'Create or Update Object',
            subscribe: 'type = "group"',
            mapping: (0, actions_core_1.defaultValues)(createUpdateObject_1.default.fields),
            type: 'automatic'
        }
    ],
    actions: {
        trackEvent: trackEvent_1.default,
        identifyUser: identifyUser_1.default,
        trackPageView: trackPageView_1.default,
        aliasUser: aliasUser_1.default,
        createUpdateObject: createUpdateObject_1.default,
        addTag: addTag_1.default,
        removeTag: removeTag_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map