"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../utils");
const common_fields_1 = require("../common-fields");
const action = {
    title: 'Conversion Adjustment Upload',
    description: 'Adjust an conversion in Campaign Manager 360.',
    fields: {
        requiredId: {
            label: 'Required ID',
            description: 'A user identifier record the conversion against. Exactly one of Google Click ID, Display Click ID, Encrypted User ID, Mobile Device ID, Match ID, Impression ID or Encrypted User ID Candidates must be provided.',
            type: 'object',
            required: true,
            properties: {
                gclid: {
                    label: 'Google Click ID',
                    description: 'The Google Click ID (gclid) associated with the conversion.',
                    type: 'string',
                    required: false
                },
                dclid: {
                    label: 'Display Click ID',
                    description: 'The Display Click ID (dclid) associated with the conversion.',
                    type: 'string',
                    required: false
                },
                encryptedUserId: {
                    label: 'Encrypted User ID',
                    description: "The encrypted user ID associated with the conversion. If this field is set then 'Encryption Entity ID', 'Encryption Entity Type' and 'Encryption Source' should also be specified.",
                    type: 'string',
                    required: false
                },
                mobileDeviceId: {
                    label: 'Mobile Device ID',
                    description: 'The mobile device ID associated with the conversion.',
                    type: 'string',
                    required: false,
                    default: {
                        '@path': '$.context.device.id'
                    }
                },
                matchId: {
                    label: 'Match ID',
                    description: 'The match ID field. A match ID is your own first-party identifier that has been synced with Google using the match ID feature in Floodlight.',
                    type: 'string',
                    required: false
                },
                impressionId: {
                    label: 'Impression ID',
                    description: 'The impression ID associated with the conversion.',
                    type: 'string',
                    required: false
                }
            },
            default: {
                gclid: {
                    '@if': {
                        exists: { '@path': '$.integrations.Campaign Manager 360.gclid' },
                        then: { '@path': '$.integrations.Campaign Manager 360.gclid' },
                        else: { '@path': '$.properties.gclid' }
                    }
                },
                dclid: {
                    '@if': {
                        exists: { '@path': '$.integrations.Campaign Manager 360.dclid' },
                        then: { '@path': '$.integrations.Campaign Manager 360.dclid' },
                        else: { '@path': '$.properties.dclid' }
                    }
                },
                encryptedUserId: { '@path': '$.userId' },
                mobileDeviceId: { '@path': '$.context.device.id' },
                matchId: { '@path': '$.properties.matchId' },
                impressionId: { '@path': '$.properties.impressionId' }
            }
        },
        ...common_fields_1.commonFields
    },
    perform: async (request, { settings, payload, auth, features }) => {
        return await (0, utils_1.send)(request, settings, [payload], true, auth, features);
    },
    performBatch: async (request, { settings, payload, auth, features }) => {
        return await (0, utils_1.send)(request, settings, payload, true, auth, features);
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map