"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const actions_core_1 = require("@segment/actions-core");
const fields_1 = require("./fields");
const functions_1 = require("./functions");
const action = {
    title: 'Purchase V2',
    description: 'Send event when a user completes a purchase',
    defaultSubscription: 'type = "track" and event = "Order Completed"',
    syncMode: {
        description: 'Define how the records from your destination will be synced.',
        label: 'How to sync records',
        default: 'add',
        choices: [{ label: 'Insert Records', value: 'add' }]
    },
    fields: fields_1.fields,
    perform: (request, { payload, settings, features, statsContext, syncMode }) => {
        if (syncMode === 'add') {
            return (0, functions_1.send)(request, payload, settings, features, statsContext);
        }
        else {
            throw new actions_core_1.IntegrationError(`Sync mode ${syncMode} is not supported`, 'Misconfigured sync mode', 400);
        }
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map