"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ticketCreated = void 0;
const types_1 = require("./types");
const dataPoints = {
    ticketId: {
        key: 'ticketId',
        valueType: 'string',
    },
};
exports.ticketCreated = {
    key: 'ticketCreated',
    dataPoints,
    onEvent: async ({ payload: { payload, rawBody, headers, settings }, onSuccess, onError, }) => {
        const parsedPayload = types_1.zTicketCreatedWebhookPayload.safeParse(payload);
        if (!parsedPayload.success) {
            await onError({
                response: {
                    statusCode: 400,
                    message: JSON.stringify(parsedPayload.error, null, 2),
                },
            });
            return;
        }
        await onSuccess({
            data_points: {
                ticketId: parsedPayload.data.freshdesk_webhook.ticket_id,
            },
        });
    },
};
//# sourceMappingURL=ticketCreated.js.map