"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../utils");
const customerio_properties_1 = require("../customerio-properties");
const action = {
    title: 'Delete Device',
    description: `Delete a person's device.`,
    defaultSubscription: 'event = "Application Uninstalled" or event = "Device Deleted"',
    fields: {
        person_id: {
            label: 'Person ID',
            description: 'The ID of the person that this mobile device belongs to.',
            type: 'string',
            required: true,
            default: {
                '@path': '$.userId'
            }
        },
        device_id: {
            label: 'Device ID',
            description: "The device token of a customer's mobile device.",
            type: 'string',
            required: true,
            default: {
                '@path': '$.context.device.token'
            }
        },
        ...customerio_properties_1.eventProperties
    },
    performBatch: (request, { payload: payloads, settings }) => {
        return (0, utils_1.sendBatch)(request, payloads.map((payload) => ({ action: 'delete_device', payload: mapPayload(payload), settings, type: 'person' })));
    },
    perform: (request, { payload, settings }) => {
        return (0, utils_1.sendSingle)(request, { action: 'delete_device', payload: mapPayload(payload), settings, type: 'person' });
    }
};
function mapPayload(payload) {
    const { device_id, ...rest } = payload;
    return {
        ...rest,
        device: {
            token: device_id
        }
    };
}
exports.default = action;
//# sourceMappingURL=index.js.map