"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const checkoutFields_1 = require("../fields/checkoutFields");
const commonFields_1 = require("../fields/commonFields");
const customerFields_1 = require("../fields/customerFields");
const routes_1 = require("../routes");
const transform_payload_1 = require("./transform-payload");
const action = {
    title: 'Save Checkout Event',
    description: 'Save a checkout event.',
    fields: {
        ...commonFields_1.commonFields,
        ...customerFields_1.customerFields,
        ...checkoutFields_1.checkoutFields,
        eventName: {
            label: 'Checkout Event Name',
            type: 'string',
            description: 'The name of the Checkout Event to track.',
            required: true,
            choices: [
                { label: 'checkout_address_info_submitted', value: 'checkout_address_info_submitted' },
                { label: 'checkout_completed', value: 'checkout_completed' },
                { label: 'checkout_contact_info_submitted', value: 'checkout_contact_info_submitted' },
                { label: 'checkout_shipping_info_submitted', value: 'checkout_shipping_info_submitted' },
                { label: 'checkout_started', value: 'checkout_started' },
                { label: 'payment_info_submitted', value: 'payment_info_submitted' }
            ]
        }
    },
    perform: (request, data) => {
        const transformedPayload = (0, transform_payload_1.transformPayload)(data.payload);
        const payload = {
            src: 'SEGMENT',
            data: [transformedPayload]
        };
        return request(routes_1.baseURL + (0, routes_1.eventsEndpoint)(data.settings.workspaceId), {
            method: 'post',
            json: payload
        });
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map