"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.validatePayloadAndCreateClient = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const zod_1 = __importDefault(require("zod"));
const client_1 = require("../api/client");
const settings_1 = require("../settings");
const validatePayloadAndCreateClient = async ({ fieldsSchema, payload, }) => {
    const { settings: { client_id, client_secret, auth_url, api_url, scope }, fields, settings, } = (0, extensions_core_1.validate)({
        schema: zod_1.default.object({
            fields: fieldsSchema,
            settings: settings_1.SettingsValidationSchema,
        }),
        payload,
    });
    const client = new client_1.AthenaAPIClient({
        authUrl: auth_url,
        requestConfig: {
            client_id,
            client_secret,
            scope,
        },
        baseUrl: api_url,
    });
    return { client, fields, settings };
};
exports.validatePayloadAndCreateClient = validatePayloadAndCreateClient;
//# sourceMappingURL=validatePayloadAndCreateClient.js.map