"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TalkdeskAPIClient = exports.TalkdeskAthenaDataWrapper = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const cacheService_1 = require("./cacheService");
class TalkdeskAthenaDataWrapper extends extensions_core_1.DataWrapper {
    /** https://docs.talkdesk.com/reference/flows-api-ref **/
    async triggerFlow({ flowId, data, }) {
        const result = await this.Request({
            method: 'POST',
            url: `flows/${flowId}/interactions`,
            headers: { 'Content-Type': 'application/json' },
            data: JSON.stringify(data),
        });
        return result;
    }
}
exports.TalkdeskAthenaDataWrapper = TalkdeskAthenaDataWrapper;
class TalkdeskAPIClient 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.cacheService,
                useHeaderInAuthorization: true,
            }),
        });
        this.ctor = (token, baseUrl) => new TalkdeskAthenaDataWrapper(token, baseUrl);
    }
    async triggerFlow({ flowId, data, }) {
        return await this.FetchData(async (dw) => await dw.triggerFlow({ flowId, data }));
    }
}
exports.TalkdeskAPIClient = TalkdeskAPIClient;
//# sourceMappingURL=talkdeskClient.js.map