"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLetter = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const client_1 = require("../../client");
const config_1 = require("./config");
exports.getLetter = {
    key: 'getLetter',
    category: extensions_core_1.Category.EHR_INTEGRATIONS,
    title: 'Get letter',
    description: 'Retrieve a letter from Elation.',
    fields: config_1.fields,
    previewable: true,
    supports_automated_retries: true,
    dataPoints: config_1.dataPoints,
    onActivityCreated: async (payload, onComplete, onError) => {
        const { letterId } = config_1.FieldsValidationSchema.parse(payload.fields);
        const api = (0, client_1.makeAPIClient)(payload.settings);
        const res = await api.getLetter(letterId);
        await onComplete({
            data_points: {
                body: res.body,
                signedBy: typeof (res === null || res === void 0 ? void 0 : res.signed_by) === 'number'
                    ? String(res.signed_by)
                    : undefined,
            },
        });
    },
};
//# sourceMappingURL=getLetter.js.map