"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 identify_1 = __importDefault(require("./identify"));
const group_1 = __importDefault(require("./group"));
const track_1 = __importDefault(require("./track"));
const presets = [
    {
        name: 'Track Event',
        subscribe: 'type = "track"',
        partnerAction: 'track',
        mapping: (0, actions_core_1.defaultValues)(track_1.default.fields),
        type: 'automatic'
    },
    {
        name: 'Identify User',
        subscribe: 'type = "identify"',
        partnerAction: 'identify',
        mapping: (0, actions_core_1.defaultValues)(identify_1.default.fields),
        type: 'automatic'
    },
    {
        name: 'Group',
        subscribe: 'type = "group"',
        partnerAction: 'group',
        mapping: (0, actions_core_1.defaultValues)(group_1.default.fields),
        type: 'automatic'
    }
];
const destination = {
    name: 'Hyperengage (Actions)',
    slug: 'actions-hyperengage',
    mode: 'cloud',
    description: 'Hyperengage actions destination, to connect your product usage data from Segment to Hyperengage',
    authentication: {
        scheme: 'custom',
        fields: {
            apiKey: {
                type: 'password',
                label: 'API Key',
                description: 'Your Hyperengage API key located in the Integration Settings page.',
                required: true
            },
            workspaceIdentifier: {
                type: 'string',
                label: 'Workspace Identifier',
                description: 'Your Hyperengage workspace identifier located in the Integration Settings page.',
                required: true
            }
        },
        testAuthentication: async (request, { settings }) => {
            return await request('https://api.hyperengage.io/api/v1/verify_api_key', {
                method: 'post',
                json: {
                    api_key: `${settings.apiKey}`,
                    workspace_identifier: `${settings.workspaceIdentifier}`
                }
            });
        }
    },
    presets,
    actions: {
        identify: identify_1.default,
        group: group_1.default,
        track: track_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map