UNPKG

@itwin/clash-detection-client

Version:

Clash Detection client for the iTwin platform

83 lines 4.81 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ import { OperationUtils } from "../OperationUtils"; import { OperationsBase } from "../../base/OperationsBase"; import { PreferReturn } from "../../base/interfaces/CommonInterfaces"; export class RunOperations extends OperationsBase { constructor(options) { super(options); } /** * Gets Runs for a specific project. This method returns Runs in their minimal representation. The * returned iterator internally queries entities in pages. Wraps the * {@link https://developer.bentley.com/apis/clash-detection/operations/get-clashdetection-runs/ Get Runs} * operation from Clash Detection API. * @param {ParamsToGetRunList} params parameters for this operation. See {@link ParamsToGetRunList}. * @returns {Promise<MinimalRun[]>} minimal Run list. See {@link MinimalRun}. */ async getMinimalList(params) { var _a; OperationUtils.ensureAccessTokenProvided(params.accessToken, this._options.accessTokenCallback); const response = await this.sendGetRequest({ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion accessToken: (_a = params.accessToken) !== null && _a !== void 0 ? _a : await this._options.accessTokenCallback(), url: this._options.urlFormatter.getRunListUrl({ urlParams: params.urlParams }), preferReturn: PreferReturn.Representation, }); return response.runs; } /** * Gets Runs for a specific project. This method returns Runs in their full representation. The returned * iterator internally queries entities in pages. Wraps the * {@link https://developer.bentley.com/apis/clash-detection/operations/get-clashdetection-runs/ Get Runs} * operation from Clash Detection API. * @param {ParamsToGetRunList} params parameters for this operation. See {@link ParamsToGetRunList}. * @returns {Promise<RunDetails[]>} array of Run details. See {@link RunDetails}. */ async getRepresentationList(params) { var _a; OperationUtils.ensureAccessTokenProvided(params.accessToken, this._options.accessTokenCallback); const response = await this.sendGetRequest({ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion accessToken: (_a = params.accessToken) !== null && _a !== void 0 ? _a : await this._options.accessTokenCallback(), url: this._options.urlFormatter.getRunListUrl({ urlParams: params.urlParams }), preferReturn: PreferReturn.Representation, }); return response.runs; } /** * Gets a single Run identified by id. This method returns a Run in its full representation. * Wraps the {@link https://developer.bentley.com/apis/clash-detection/operations/get-clashdetection-run/ * Get Run} operation from Clash Detection API. * @param {ParamsToGetRun} params parameters for this operation. See {@link ParamsToGetRun}. * @returns {Promise<RunDetails>} a Run with specified id. See {@link RunDetails}. */ async getSingle(params) { const { accessToken, runId } = params; OperationUtils.ensureAccessTokenProvided(accessToken, this._options.accessTokenCallback); const response = await this.sendGetRequest({ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion accessToken: accessToken !== null && accessToken !== void 0 ? accessToken : await this._options.accessTokenCallback(), url: this._options.urlFormatter.getSingleRunUrl({ runId }), }); return response.run; } /** * Deletes a Run. Wraps the {@link https://developer.bentley.com/apis/clash-detection/operations/delete-clashdetection-run/ * Delete Run} operation from Clash Detection API. * @param {ParamsToDeleteRun} params parameters for this operation. See {@link ParamsToDeleteRun}. * @returns {Promise<void>}. */ async delete(params) { var _a; OperationUtils.ensureAccessTokenProvided(params.accessToken, this._options.accessTokenCallback); await this.sendDeleteRequest({ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion accessToken: (_a = params.accessToken) !== null && _a !== void 0 ? _a : await this._options.accessTokenCallback(), url: this._options.urlFormatter.deleteRunUrl(params), }); } } //# sourceMappingURL=RunOperations.js.map