@itwin/insights-client
Version:
Insights client for the iTwin platform
35 lines • 1.59 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { CARBON_CALCULATION_BASE_PATH, OperationsBase } from "../../common/OperationsBase";
export class OCLCAJobsClient extends OperationsBase {
constructor(basePath) {
super(basePath ?? 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;
}
}
//# sourceMappingURL=OCLCAJobsClient.js.map