"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const request_utils_1 = require("../request-utils");
const action = {
    title: 'Identify Company',
    description: 'Defines a company in Userpilot, you can visit [Userpilot docs](https://docs.userpilot.com/article/23-identify-users-track-custom-events) for more information.',
    defaultSubscription: 'type = "group"',
    fields: {
        groupId: {
            type: 'string',
            required: true,
            description: 'The ID of the company.',
            label: 'Company ID',
            default: {
                '@path': '$.groupId'
            }
        },
        createdAt: {
            type: 'datetime',
            required: false,
            description: 'The date the company profile was created at',
            label: 'Company Created At Date',
            default: {
                '@path': '$.traits.createdAt'
            }
        },
        traits: {
            type: 'object',
            required: false,
            description: 'Segment traits',
            label: 'Traits',
            default: {
                '@path': '$.traits'
            }
        }
    },
    perform: (request, { settings, payload }) => {
        const { traits, groupId, createdAt } = payload;
        traits?.createdAt && delete traits.createdAt;
        const { url, options } = (0, request_utils_1.getCompanyIdentifyRequestParams)(settings, {
            traits: { ...traits, created_at: createdAt || traits?.created_at },
            groupId
        });
        return request(url, options);
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map