"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DockAPIClient = exports.DockDataWrapper = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const cacheService_1 = require("./cacheService");
class DockDataWrapper extends extensions_core_1.DataWrapper {
    constructor(token, baseUrl, dockOpts) {
        super(token, baseUrl);
        this.apiKey = dockOpts.apiKey;
        this.organizationId = dockOpts.organizationId;
        this.userId = dockOpts.userId;
    }
    async getPatient(input) {
        const res = await this.Request({
            method: 'GET',
            url: `/api/v1/patient/${input.id}`,
            headers: {
                'x-api-key': this.apiKey,
                'x-user-id': this.userId,
                'x-organization-id': this.organizationId,
            },
        });
        return res;
    }
    async createTask(input) {
        const res = await this.Request({
            method: 'POST',
            url: `/api/v1/task`,
            headers: {
                'x-api-key': this.apiKey,
                'x-user-id': this.userId,
                'x-organization-id': this.organizationId,
            },
            data: JSON.stringify(input),
        });
        return res;
    }
}
exports.DockDataWrapper = DockDataWrapper;
class DockAPIClient extends extensions_core_1.APIClient {
    constructor({ authUrl, requestConfig, ...opts }) {
        super({
            ...opts,
            auth: new extensions_core_1.OAuthClientCredentials({
                auth_url: authUrl,
                request_config: requestConfig,
                cacheService: cacheService_1.dockCacheService,
            }),
        });
        this.ctor = (token, baseUrl) => new DockDataWrapper(token, baseUrl, {
            apiKey: this.apiKey,
            organizationId: this.organizatinId,
            userId: this.userId,
        });
        this.apiKey = opts.apiKey;
        this.organizatinId = opts.organizationId;
        this.userId = opts.userId;
    }
    async getPatient(input) {
        return await this.FetchData(async (dw) => await dw.getPatient(input));
    }
    async createTask(input) {
        return await this.FetchData(async (dw) => await dw.createTask(input));
    }
}
exports.DockAPIClient = DockAPIClient;
//# sourceMappingURL=client.js.map