"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const t1_properties_1 = require("../t1-properties");
const action = {
    title: '[Deprecated] Upsert customer profile',
    description: `This updates attributes and audiences for a single customer profile. **Important:** This Action is deprecated. Use the **Update customer profile** Action instead.`,
    fields: {
        attributes: { ...t1_properties_1.attribute },
        customerProfileId: { ...t1_properties_1.customerProfileId },
        deleteAudienceIds: { ...t1_properties_1.deleteAudienceId },
        addAudienceIds: { ...t1_properties_1.addAudienceId },
        runRuleEngine: {
            label: 'Run rule engine',
            description: 'This runs rule engine in Talon.One upon updating customer profile. Set to true to trigger rules. Setting this property to false improves response times. For audiences changes the runRuleEngine should be true. Default value is false.',
            type: 'boolean',
            default: false
        },
        attributesInfo: {
            label: 'Attributes with types',
            description: 'Use this field if you want to identify an attribute with a specific type',
            type: 'object',
            required: false,
            multiple: true,
            properties: {
                name: {
                    label: 'Name',
                    description: 'Attribute name',
                    type: 'string',
                    required: true
                },
                type: {
                    label: 'Type',
                    description: 'Attribute type. Can be only `string`, `time`, `number`, `boolean`, `location`',
                    type: 'string',
                    required: true
                }
            },
            default: {
                '@arrayPath': [
                    '$.traits.attributesInfo',
                    {
                        name: {
                            '@path': '$.name'
                        },
                        type: {
                            '@path': '$.type'
                        }
                    }
                ]
            }
        }
    },
    perform: (request, { payload }) => {
        return request(`https://integration.talon.one/segment/customer_profile/${payload.customerProfileId}`, {
            method: 'put',
            json: {
                attributes: payload.attributes,
                audiencesChanges: {
                    adds: payload.addAudienceIds,
                    deletes: payload.deleteAudienceIds
                },
                runRuleEngine: payload.runRuleEngine,
                attributesInfo: payload.attributesInfo
            }
        });
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map