"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 api_1 = require("./api");
const submitTrackEvent_1 = __importDefault(require("./submitTrackEvent"));
const submitIdentifyEvent_1 = __importDefault(require("./submitIdentifyEvent"));
const submitPageEvent_1 = __importDefault(require("./submitPageEvent"));
const submitScreenEvent_1 = __importDefault(require("./submitScreenEvent"));
const destination = {
    name: 'Saleswings (Actions)',
    slug: 'actions-saleswings',
    mode: 'cloud',
    authentication: {
        scheme: 'custom',
        fields: {
            apiKey: {
                label: 'API Key',
                description: 'Segment.io API key for your SalesWings project.',
                type: 'password',
                required: true
            },
            environment: {
                label: 'Environment',
                description: 'SalesWings environment this destination is connected with.',
                type: 'string',
                choices: [
                    { value: 'helium', label: 'Helium (live environment)' },
                    { value: 'ozone', label: 'Ozone (test environment)' }
                ],
                required: true,
                default: 'helium'
            }
        },
        testAuthentication: async (request, { settings }) => {
            return request((0, api_1.getAccountUrl)(settings.environment), {
                headers: { Authorization: `Bearer ${settings.apiKey}` }
            });
        }
    },
    presets: [
        {
            name: 'Submit Track Event',
            subscribe: 'type = "track"',
            partnerAction: 'submitTrackEvent',
            mapping: (0, actions_core_1.defaultValues)(submitTrackEvent_1.default.fields),
            type: 'automatic'
        },
        {
            name: 'Submit Identify Event',
            subscribe: 'type = "identify"',
            partnerAction: 'submitIdentifyEvent',
            mapping: (0, actions_core_1.defaultValues)(submitIdentifyEvent_1.default.fields),
            type: 'automatic'
        },
        {
            name: 'Submit Page Event',
            subscribe: 'type = "page"',
            partnerAction: 'submitPageEvent',
            mapping: (0, actions_core_1.defaultValues)(submitPageEvent_1.default.fields),
            type: 'automatic'
        },
        {
            name: 'Submit Screen Event',
            subscribe: 'type = "screen"',
            partnerAction: 'submitScreenEvent',
            mapping: (0, actions_core_1.defaultValues)(submitScreenEvent_1.default.fields),
            type: 'automatic'
        }
    ],
    actions: {
        submitTrackEvent: submitTrackEvent_1.default,
        submitIdentifyEvent: submitIdentifyEvent_1.default,
        submitPageEvent: submitPageEvent_1.default,
        submitScreenEvent: submitScreenEvent_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map