@itwin/insights-client
Version:
Insights client for the iTwin platform
39 lines • 1.75 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.OCLCAJobsClient = void 0;
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
const OperationsBase_1 = require("../../common/OperationsBase");
class OCLCAJobsClient extends OperationsBase_1.OperationsBase {
constructor(basePath) {
super(basePath ?? OperationsBase_1.CARBON_CALCULATION_BASE_PATH);
}
async getOCLCAAccessToken(username, password) {
if (username === undefined || password === undefined) {
return undefined;
}
const requestOptions = {
method: "POST",
};
requestOptions.body = JSON.stringify({
username,
password,
});
const url = `https://oneclicklcaapp.com/app/api/login`;
return this.fetchJSON(url, requestOptions);
}
async createJob(accessToken, job) {
const url = `${this.basePath}/oneclicklca/jobs`;
const requestOptions = this.createRequest("POST", accessToken, JSON.stringify(job));
return (await this.fetchJSON(url, requestOptions)).job;
}
async getOCLCAJobStatus(accessToken, jobId) {
const url = `${this.basePath}/oneclicklca/jobs/${jobId}`;
const requestOptions = this.createRequest("GET", accessToken);
return (await this.fetchJSON(url, requestOptions)).job;
}
}
exports.OCLCAJobsClient = OCLCAJobsClient;
//# sourceMappingURL=OCLCAJobsClient.js.map