"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BASE_URL = void 0;
const actions_core_1 = require("@segment/actions-core");
const postEvent_1 = __importDefault(require("./postEvent"));
exports.BASE_URL = 'https://postback.iqm.com/open?pid=segment';
const destination = {
    name: 'Iqm',
    slug: 'actions-iqm',
    mode: 'cloud',
    description: 'Send Segment events to IQM',
    authentication: {
        scheme: 'custom',
        fields: {
            pixel_id: {
                label: 'Pixel ID',
                description: 'The Pixel ID for your IQM Conversion.',
                type: 'string',
                required: true
            }
        }
    },
    onDelete: async (request, { settings, payload }) => {
        const { pixel_id } = settings;
        await request(`${exports.BASE_URL}&pixel_id=${pixel_id}`, {
            method: 'delete',
            headers: { HOST: 'postback.iqm.com', 'Content-Type': 'application/json' },
            body: JSON.stringify(payload)
        });
    },
    actions: {
        postEvent: postEvent_1.default
    },
    presets: [
        {
            name: 'Send an event to IQM',
            subscribe: 'type = "track"',
            partnerAction: 'postEvent',
            mapping: (0, actions_core_1.defaultValues)(postEvent_1.default.fields),
            type: 'automatic'
        }
    ]
};
exports.default = destination;
//# sourceMappingURL=index.js.map