"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeAPIClient = exports.ZusHealthAPIClient = exports.ZusHealthDataWrapper = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const validation_1 = require("../validation");
class ZusHealthDataWrapper extends extensions_core_1.DataWrapper {
    async getResource(resourceId) {
        const response = await this.RequestRaw({
            method: 'GET',
            url: `/${resourceId}`,
        });
        return response;
    }
}
exports.ZusHealthDataWrapper = ZusHealthDataWrapper;
class ZusHealthAPIClient extends extensions_core_1.APIClient {
    constructor({ authUrl, requestConfig, ...opts }) {
        super({
            ...opts,
            auth: new extensions_core_1.OAuthClientCredentials({
                auth_url: authUrl,
                request_config: requestConfig,
            }),
        });
        this.ctor = (token, baseUrl) => new ZusHealthDataWrapper(token, baseUrl);
    }
    async getResource(resourceId) {
        const response = await this.FetchData(async (dw) => await dw.getResource(resourceId));
        return response.data;
    }
}
exports.ZusHealthAPIClient = ZusHealthAPIClient;
const makeAPIClient = (payloadSettings) => {
    const { auth_url, base_url, ...authRquestSettings } = validation_1.settingsSchema.parse(payloadSettings);
    return new ZusHealthAPIClient({
        authUrl: auth_url,
        requestConfig: authRquestSettings,
        baseUrl: base_url,
    });
};
exports.makeAPIClient = makeAPIClient;
//# sourceMappingURL=client.js.map