"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const cordial_client_1 = __importDefault(require("../cordial-client"));
const identities_fields_1 = __importDefault(require("../identities-fields"));
const action = {
    title: 'Add Product to Cart',
    description: 'Add product to Cordial contact cart',
    defaultSubscription: 'type = "track" and event = "Product Added"',
    fields: {
        ...identities_fields_1.default,
        productID: {
            label: 'Product ID',
            description: 'Internal identifier of a product',
            type: 'string',
            required: true,
            default: {
                '@path': '$.properties.product_id'
            }
        },
        sku: {
            label: 'SKU',
            description: 'SKU of a product',
            type: 'string',
            required: true,
            default: {
                '@path': '$.properties.sku'
            }
        },
        qty: {
            label: 'Quantity',
            description: 'Quantity of a product',
            type: 'integer',
            required: true,
            default: {
                '@path': '$.properties.quantity'
            }
        },
        category: {
            label: 'Category',
            description: 'Category of a product',
            type: 'string',
            required: true,
            default: {
                '@path': '$.properties.category'
            }
        },
        name: {
            label: 'Name',
            description: 'Name of a product',
            type: 'string',
            required: true,
            default: {
                '@path': '$.properties.name'
            }
        },
        description: {
            label: 'Description',
            description: 'Description of a product',
            type: 'string',
            required: false
        },
        itemPrice: {
            label: 'Price',
            description: 'Price of a product',
            type: 'number',
            required: false,
            default: {
                '@path': '$.properties.price'
            }
        },
        url: {
            label: 'URL',
            description: 'URL of a product',
            type: 'string',
            required: false,
            default: {
                '@path': '$.properties.url'
            }
        },
        imageUrl: {
            label: 'Image URL',
            description: 'Image of a product',
            type: 'string',
            required: false,
            default: {
                '@path': '$.properties.image_url'
            }
        },
        properties: {
            label: 'Properties',
            description: 'Properties of a product (e.g brand, color, size)',
            type: 'object',
            required: false,
            default: {
                brand: { '@path': '$.properties.brand' },
                variant: { '@path': '$.properties.variant' },
                coupon: { '@path': '$.properties.coupon' }
            },
            defaultObjectUI: 'keyvalue:only'
        },
    },
    perform: (request, { settings, payload }) => {
        const client = new cordial_client_1.default(settings, request);
        return client.addProductToCart(payload);
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map