"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("../index");
const action = {
    title: 'Send Custom Event',
    description: 'Send a custom event to Actable for prediction. Use this to supply events that are not in Actable \'s customer view.',
    fields: {
        customer_id: {
            label: 'Customer ID',
            description: 'The unique user identifier.',
            type: 'string',
            required: true,
            default: {
                '@path': '$.userId'
            }
        },
        timestamp: {
            type: "datetime",
            label: "Timestamp of Event",
            description: "Timestamp of when the custom event occured.",
            required: true,
            default: {
                '@path': '$.timestamp'
            }
        },
        properties: {
            type: "object",
            label: "Custom Properties",
            description: "Send an object of custom properties to Actable Predictive for custom data modeling.",
            required: true,
            default: { '@path': '$.properties' }
        },
        stream_key: {
            type: "string",
            label: "Stream Key",
            description: "Dataset label, should be left as default unless specified otherwise.",
            required: true,
            default: "custom"
        }
    },
    perform: (request, data) => {
        data.payload.timestamp = (0, index_1.formatTimestampAsUnixSeconds)(data.payload.timestamp);
        return request(index_1.API_URL, {
            method: 'post',
            json: { data: [data.payload] }
        });
    },
    performBatch: (request, data) => {
        for (const ev of data.payload) {
            ev.timestamp = (0, index_1.formatTimestampAsUnixSeconds)(ev.timestamp);
        }
        return request(index_1.API_URL, {
            method: 'post',
            json: { data: data.payload }
        });
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map