"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const event_1 = require("../common/event");
const fields_1 = require("../common/fields");
const request_client_1 = require("../common/request-client");
const convert_1 = require("../common/convert");
const action = {
    title: 'Add to Cart',
    description: 'Represents a user adding an item to their cart',
    defaultSubscription: 'type = "track" and event = "Product Added"',
    fields: {
        event_id: fields_1.event_id,
        timestamp: fields_1.timestamp,
        user_id: fields_1.user_id,
        device: fields_1.device,
        session_id: fields_1.session_id,
        default_currency: fields_1.default_currency,
        items: {
            ...fields_1.items,
            required: true,
            default: {
                '@arrayPath': [
                    '$.properties',
                    {
                        id: { '@path': '$.product_id' },
                        price: { '@path': '$.price' },
                        currency: { '@path': '$.currency' },
                        quantity: { '@path': '$.quantity' },
                        seller_id: { '@path': '$.seller_id' }
                    }
                ]
            }
        },
        page_id: fields_1.page_id,
        page_identifier_tokens: fields_1.page_identifier_tokens
    },
    perform: (request, { payload, settings }) => {
        const client = new request_client_1.MolocoAPIClient(request, settings);
        const body = (0, convert_1.convertEvent)({ eventType: event_1.EventType.AddToCart, payload, settings });
        return client.sendEvent(body);
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map