"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const request_params_1 = require("../request-params");
const common_definitions_1 = require("../common-definitions");
const action = {
    title: 'Identify User',
    description: 'Sets a user data.',
    platform: 'cloud',
    fields: {
        user_id: {
            type: 'string',
            required: true,
            description: 'The user id, to uniquely identify the user',
            label: 'User id',
            default: { '@path': '$.userId' }
        },
        user_email: {
            type: 'string',
            required: true,
            description: 'The user email address',
            label: 'Email address',
            default: {
                '@if': {
                    exists: { '@path': '$.traits.email' },
                    then: { '@path': '$.traits.email' },
                    else: { '@path': '$.properties.email' }
                }
            }
        },
        user_created_at: {
            type: 'string',
            required: false,
            description: 'The timestamp when the user was created',
            label: 'Created at',
            default: { '@path': '$.traits.created_at' }
        },
        user_first_name: {
            type: 'string',
            required: false,
            description: 'The user first name',
            label: 'First name',
            default: {
                '@if': {
                    exists: { '@path': '$.traits.first_name' },
                    then: { '@path': '$.traits.first_name' },
                    else: { '@path': '$.properties.first_name' }
                }
            }
        },
        user_last_name: {
            type: 'string',
            required: false,
            description: 'The user last name',
            label: 'Last name',
            default: {
                '@if': {
                    exists: { '@path': '$.traits.last_name' },
                    then: { '@path': '$.traits.last_name' },
                    else: { '@path': '$.properties.last_name' }
                }
            }
        },
        user_custom_attributes: {
            type: 'object',
            required: false,
            description: 'The user custom attributes',
            label: 'Custom attributes',
            default: {
                '@path': '$.traits'
            }
        },
        ...common_definitions_1.commonFields
    },
    perform: (request, { payload, settings }) => {
        const resolvedPayload = (0, request_params_1.resolveRequestPayload)(settings, payload);
        const { url, options } = (0, request_params_1.eventRequestParams)(settings, resolvedPayload, 'user_identify');
        return request(url, options);
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map