"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const dayjs_1 = __importDefault(require("dayjs"));
const constants_1 = require("../constants");
const action = {
    title: 'Send Account Profiles',
    description: 'Send group calls to Toplyne',
    defaultSubscription: 'type = "group"',
    fields: {
        accountId: {
            type: 'string',
            label: 'Account ID',
            description: 'The ID of the account to send properties for',
            required: true,
            default: { '@path': '$.groupId' }
        },
        creationTime: {
            type: 'datetime',
            label: 'Creation time',
            description: 'Toplyne calculates the creation time using the timestamp of the first event or group call',
            required: true,
            default: { '@path': '$.timestamp' }
        },
        accountProperties: {
            type: 'object',
            label: 'Account Properties',
            description: 'The properties of the account',
            required: false,
            default: { '@path': '$.traits' }
        }
    },
    perform: (request, data) => {
        return request(`${constants_1.baseUrl}/upload/accounts/profiles`, {
            json: {
                accounts: [
                    {
                        ...data.payload,
                        creationTime: (0, dayjs_1.default)(data.payload.creationTime).unix()
                    }
                ]
            }
        });
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map