"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.callCompleted = void 0;
const lodash_1 = require("lodash");
const dataPoints = {
    callId: {
        key: 'callId',
        valueType: 'string',
    },
    callObject: {
        key: 'callObject',
        valueType: 'json',
    },
};
exports.callCompleted = {
    key: 'callCompleted',
    dataPoints,
    onEvent: async ({ payload: { payload, rawBody, headers, settings }, onSuccess, onError, }) => {
        const callId = payload === null || payload === void 0 ? void 0 : payload.call_id;
        if ((0, lodash_1.isNil)(callId)) {
            await onError({
                response: {
                    statusCode: 400,
                    message: 'Missing call_id in payload',
                },
            });
        }
        await onSuccess({
            data_points: {
                callId,
                callObject: JSON.stringify(payload),
            },
        });
    },
};
//# sourceMappingURL=callCompleted.js.map