"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.validatePayloadAndCreateSdk = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const zod_1 = __importDefault(require("zod"));
const settings_1 = require("../settings");
const client_1 = require("./api/client");
const validatePayloadAndCreateSdk = async ({ fieldsSchema, payload, }) => {
    const { settings, fields } = (0, extensions_core_1.validate)({
        schema: zod_1.default.object({
            fields: fieldsSchema,
            settings: settings_1.SettingsValidationSchema.extend({
                productId: zod_1.default
                    .string()
                    .min(1, 'Product ID is required to use the WestFax API'),
            }),
        }),
        payload,
    });
    const { patient, pathway, activity } = payload;
    const baseUrl = `https://api2.westfax.com/REST`;
    const westFaxSdk = new client_1.WestFaxApiClient({
        baseUrl,
        username: settings.username,
        password: settings.password,
        productId: settings.productId,
    });
    return {
        westFaxSdk,
        settings,
        fields,
        patient,
        pathway,
        activity,
    };
};
exports.validatePayloadAndCreateSdk = validatePayloadAndCreateSdk;
//# sourceMappingURL=validatePayloadAndCreateSdk.js.map