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