"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 sync_1 = __importDefault(require("./sync"));
const constants_1 = require("./constants");
const destination = {
    name: 'Vibe Audience',
    slug: 'actions-vibe-audience',
    mode: 'cloud',
    description: 'Sync Segment Engage Audiences to Vibe',
    authentication: {
        scheme: 'custom',
        fields: {
            advertiserId: {
                type: 'string',
                label: 'Advertiser ID',
                description: 'Your Vibe advertiser ID.',
                required: true
            },
            authToken: {
                type: 'string',
                label: 'Auth Token',
                description: 'Your Vibe authentication token.',
                required: true,
                format: 'password'
            }
        },
        testAuthentication: async (request, { settings }) => {
            return request(`${constants_1.BASE_URL}/${constants_1.API_VERSION}/webhooks/twilio/${settings.advertiserId}`, {
                method: 'GET'
            });
        }
    },
    extendRequest({ settings }) {
        return {
            headers: {
                'x-api-key': settings.authToken,
                'Content-Type': 'application/json'
            }
        };
    },
    actions: {
        sync: sync_1.default
    },
    presets: [
        {
            name: 'Sync Engage Audience',
            subscribe: 'type = "identify" or type = "track"',
            partnerAction: 'sync',
            mapping: (0, actions_core_1.defaultValues)(sync_1.default.fields),
            type: 'automatic'
        }
    ]
};
exports.default = destination;
//# sourceMappingURL=index.js.map