"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const validateInput_1 = require("../validateInput");
const commonFields_1 = require("../commonFields");
const action = {
    title: 'Group',
    description: 'Send group calls to Hyperengage.',
    defaultSubscription: 'type = "group"',
    fields: {
        account_id: {
            type: 'string',
            required: true,
            description: 'The External ID of the account to send properties for',
            label: 'Account id',
            default: {
                '@if': {
                    exists: { '@path': '$.context.group_id' },
                    then: { '@path': '$.context.group_id' },
                    else: { '@path': '$.groupId' }
                }
            }
        },
        user_id: {
            type: 'string',
            description: 'The ID associated with the user',
            label: 'User ID',
            default: { '@path': '$.userId' }
        },
        name: {
            type: 'string',
            required: true,
            description: 'The Account name',
            label: 'Account name',
            default: {
                '@if': {
                    exists: { '@path': '$.traits.name' },
                    then: { '@path': '$.traits.name' },
                    else: { '@path': '$.properties.name' }
                }
            }
        },
        created_at: {
            type: 'string',
            required: false,
            description: 'The timestamp when the account was created, represented in the ISO-8601 date format. For instance, "2023-09-26T15:30:00Z".',
            label: 'Account created at',
            default: {
                '@if': {
                    exists: { '@path': '$.traits.created_at' },
                    then: { '@path': '$.traits.created_at' },
                    else: { '@path': '$.traits.createdAt' }
                }
            }
        },
        traits: {
            type: 'object',
            required: false,
            description: 'The properties of the account',
            label: 'Account properties',
            default: { '@path': '$.traits' }
        },
        plan: {
            type: 'string',
            required: false,
            description: 'Subscription plan the account is associated with',
            label: 'Account subscription plan',
            default: {
                '@if': {
                    exists: { '@path': '$.traits.plan' },
                    then: { '@path': '$.traits.plan' },
                    else: { '@path': '$.traits.plan_name' }
                }
            }
        },
        industry: {
            type: 'string',
            required: false,
            description: 'The account industry',
            label: 'Account industry',
            default: { '@path': '$.traits.industry' }
        },
        website: {
            type: 'string',
            required: false,
            description: 'The account website',
            label: 'Account website',
            default: { '@path': '$.traits.website' }
        },
        ...commonFields_1.commonFields
    },
    perform: (request, data) => {
        return request(`https://events.hyperengage.io/api/v1/s2s/event?token=${data.settings.apiKey}`, {
            method: 'post',
            json: (0, validateInput_1.validateInput)(data.settings, data.payload, 'account_identify')
        });
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map