"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const actions_core_1 = require("@segment/actions-core");
const action = {
    title: 'Send Entire Event',
    description: 'Send an entire Segment event to Movable Ink',
    fields: {
        headers: {
            label: 'Headers',
            description: 'HTTP headers to send with each request. Only ASCII characters are supported.',
            type: 'object',
            defaultObjectUI: 'keyvalue:only'
        },
        data: {
            label: 'Data',
            description: 'Payload to deliver to webhook URL (JSON-encoded).',
            type: 'object',
            default: { '@path': '$.' }
        }
    },
    perform: (request, { settings, payload }) => {
        const url = settings.movable_ink_url;
        if (!url)
            throw new actions_core_1.IntegrationError('"Movable Ink URL" setting or "Movable Ink URL" field must be populated', 'MISSING_DESTINATION_URL', 400);
        try {
            return request(url, {
                method: 'POST',
                headers: payload.headers,
                json: payload.data
            });
        }
        catch (error) {
            if (error instanceof TypeError)
                throw new actions_core_1.PayloadValidationError(error.message);
            throw error;
        }
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map