"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 updateProfile_1 = __importDefault(require("./updateProfile"));
const constants_1 = require("./constants");
const destination = {
    name: 'Batch (Actions)',
    slug: 'actions-batch',
    mode: 'cloud',
    authentication: {
        scheme: 'custom',
        fields: {
            apiToken: {
                label: 'REST API Key',
                description: 'Token used to authorize sending data to the Destination platform',
                type: 'password',
                required: true
            },
            projectKey: {
                label: 'Project Key',
                description: 'The unique project key identifying your project in the Destination platform',
                type: 'string',
                required: true
            }
        },
        testAuthentication: async (request) => {
            return await request(`https://api.batch.com/${constants_1.API_VERSION}/profiles/update`, {
                method: 'POST',
                body: JSON.stringify([
                    {
                        identifiers: {
                            custom_id: 'test-custom-id'
                        }
                    }
                ])
            });
        }
    },
    extendRequest({ settings }) {
        return {
            headers: {
                'Content-Type': 'application/json',
                Authorization: `Bearer ${settings.apiToken}`,
                'X-Batch-Project': `${settings.projectKey}`
            }
        };
    },
    actions: {
        updateProfile: updateProfile_1.default
    },
    presets: [
        {
            name: 'Update Profile',
            subscribe: 'type = "identify" or type = "track"',
            partnerAction: 'updateProfile',
            mapping: (0, actions_core_1.defaultValues)(updateProfile_1.default.fields),
            type: 'automatic'
        }
    ]
};
exports.default = destination;
//# sourceMappingURL=index.js.map