"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const syncEvent_1 = __importDefault(require("./syncEvent"));
const syncUserProfile_1 = __importDefault(require("./syncUserProfile"));
const destination = {
    name: 'Taguchi',
    slug: 'actions-taguchi',
    mode: 'cloud',
    description: 'Sync analytics events, user profile details, including Audience and Computed Trait details to Taguchi.',
    authentication: {
        scheme: 'custom',
        fields: {
            apiKey: {
                label: 'API Key',
                description: 'Taguchi API Key used to authenticate requests to the Taguchi platform.',
                type: 'password',
                required: true
            },
            integrationURL: {
                label: 'Integration URL',
                description: "The Taguchi URL Segment will send data to. This should be created in the Taguchi User Interface by navigating to 'Taguchi Integrations' then 'Integrations Setup.'",
                type: 'string',
                required: true
            },
            organizationId: {
                label: 'Organization ID',
                description: 'The Taguchi ID of the organization to which this Subscriber belongs.',
                type: 'string',
                required: true
            }
        },
        testAuthentication: (request, { settings }) => {
            const testUrl = settings.integrationURL.replace('/prod', '/test');
            return request(`${testUrl}/subscriber`, {
                method: 'POST',
                json: [
                    {
                        profile: {
                            organizationId: Number(settings.organizationId),
                            ref: 'test-connection',
                            firstname: 'Test'
                        }
                    }
                ],
                headers: {
                    'Content-Type': 'application/json',
                    Authorization: `Bearer ${settings.apiKey}`
                }
            });
        }
    },
    actions: {
        syncEvent: syncEvent_1.default,
        syncUserProfile: syncUserProfile_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map