"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fields_1 = require("../fields");
const constants_1 = require("../constants");
const functions_1 = require("../functions");
const action = {
    title: 'Send Ecommerce Event',
    description: 'Send Segment ecommerce events to Attentive.',
    defaultSubscription: 'event = "Product Viewed" or event = "Product Added" or event = "Order Completed"',
    fields: {
        userIdentifiers: fields_1.userIdentifiers,
        occurredAt: fields_1.occurredAt,
        eventType: fields_1.eventType,
        items: fields_1.items
    },
    perform: (request, { payload }) => {
        (0, functions_1.validate)(payload);
        const { eventType } = payload;
        return request(`${constants_1.API_URL}/${constants_1.API_VERSION}/events/ecommerce/${eventType}`, {
            method: 'POST',
            json: (0, functions_1.formatEcommEventJSON)(payload)
        });
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map