UNPKG

@mindconnect/mindconnect-nodejs

Version:

NodeJS Library for Siemens Insights Hub Connectivity - TypeScript SDK for Insights Hub and Industrial IoT - Command Line Interface - Insights Hub Development Proxy (Siemens Insights Hub was formerly known as MindSphere)

408 lines 15.7 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.CaseManagementClient = void 0; const utils_1 = require("../../utils"); const sdk_client_1 = require("../common/sdk-client"); /** * * Case Management API * case solution building block provides a workflow for maintenance, repair, inspection and incident handling requests. * * This workflow would enable user to * Digitalize preventive maintenance - cases for planned maintenance requests (insights from condition monitoring, prescribed by manufacturer, * dictated by performance, required by policies) * Digitalize corrective maintenance - cases for incident handling and repair requests (alerts from condition monitoring, observations) * Digitalize compliance to regulations - Audit of inspection records * Improve work request coordination leading to improvement in productivity * Improve work request efficiency - right information at right place at right time case solution building block would enable user * by allowing to create, monitor and update cases in multiple ways. * * @export * @class CaseManagementClient * @extends {SdkClient} */ class CaseManagementClient extends sdk_client_1.SdkClient { constructor() { super(...arguments); this._baseUrl = "/api/casemanagement/v3"; } /** * * Retrieves the list of cases for the tenant. * * @param {{ * page?: number; * size?: number; * sort?: string; * filter?: string; * }} [params] * @return {*} {Promise<CaseManagementModels.CaseListResponse>} * @memberof CaseManagementClient */ GetCases(params) { return __awaiter(this, void 0, void 0, function* () { const parameters = params || {}; const { page, size, sort, filter } = parameters; const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/cases?${(0, utils_1.toQueryString)({ page, size, sort, filter })}`, }); return result; }); } /** * Create case * * @param {CaseManagementModels.CaseRequestDTO} caseRequest * @return {*} {Promise<CaseManagementModels.CaseSuccessResponseStatus>} * @memberof CaseManagementClient */ CreateCase(caseRequest) { return __awaiter(this, void 0, void 0, function* () { const result = yield this.HttpAction({ verb: "POST", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/cases`, body: caseRequest, }); return result; }); } /** * Get list of all cases activities * * @param {{ * page?: number; * size?: number; * sort?: string; * filter?: string; * }} [params] * @return {*} {Promise<CaseManagementModels.CaseActivitiesListResponse>} * @memberof CaseManagementClient */ GetCasesActivities(params) { return __awaiter(this, void 0, void 0, function* () { const parameters = params || {}; const { page, size, sort, filter } = parameters; const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/cases/activities?${(0, utils_1.toQueryString)({ page, size, sort, filter })}`, }); return result; }); } /** * Get list of cases comments * * @param {{ * page?: number; * size?: number; * sort?: string; * filter?: string; * }} [params] * @return {*} {Promise<CaseManagementModels.CaseCommentsListResponse>} * @memberof CaseManagementClient */ GetCasesComments(params) { return __awaiter(this, void 0, void 0, function* () { const parameters = params || {}; const { page, size, sort, filter } = parameters; const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/cases/comments?${(0, utils_1.toQueryString)({ page, size, sort, filter })}`, }); return result; }); } /** * Get aggregate summary of the case * * @param {{ * includeOnly?: string; * }} [params] * @return {*} {Promise<CaseManagementModels.CaseAggregateResponse>} * @memberof CaseManagementClient */ GetCasesAggregate(params) { return __awaiter(this, void 0, void 0, function* () { const parameters = params || {}; const { includeOnly } = parameters; const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/cases/aggregate?${(0, utils_1.toQueryString)({ includeOnly })}`, }); return result; }); } /** * Retrieve case for given case handle * * @param {string} handle * @return {*} {Promise<CaseManagementModels.CaseResponse>} * @memberof CaseManagementClient */ GetCase(handle) { return __awaiter(this, void 0, void 0, function* () { const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/cases/${handle}`, }); return result; }); } /** * Update case for given case handle. * * @param {string} handle * @param {CaseManagementModels.CaseRequestDTO} caseRequest * @param {{ ifMatch: string }} params * @return {*} {Promise<CaseManagementModels.CaseResponseStatus>} * @memberof CaseManagementClient */ UpdateCase(handle, caseRequest, params) { return __awaiter(this, void 0, void 0, function* () { const parameters = params || {}; const { ifMatch } = parameters; const result = yield this.HttpAction({ verb: "PUT", body: caseRequest, gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/cases/${handle}`, additionalHeaders: { "If-Match": ifMatch }, }); return result; }); } /** * Delete case for given case handle * * @param {string} handle * @param {{ ifMatch: string }} params * @memberof CaseManagementClient */ DeleteCase(handle, params) { return __awaiter(this, void 0, void 0, function* () { const parameters = params || {}; const { ifMatch } = parameters; yield this.HttpAction({ verb: "DELETE", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/cases/${handle}`, additionalHeaders: { "If-Match": ifMatch }, noResponse: true, }); }); } /** * Partial update attachments case for given case handle * * @param {string} handle * @param {CaseManagementModels.AttachmentsRequestDTO} attachementRequestDto * @param {{ ifMatch: string }} params * @return {*} {Promise<CaseManagementModels.CaseSuccessResponseStatus>} * @memberof CaseManagementClient */ UpdateAttachments(handle, attachementRequestDto, params) { return __awaiter(this, void 0, void 0, function* () { const parameters = params || {}; const { ifMatch } = parameters; const result = yield this.HttpAction({ verb: "PATCH", body: attachementRequestDto, gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/cases/${handle}/attachments`, additionalHeaders: { "If-Match": ifMatch }, }); return result; }); } /** * Partial update associations case for given case handle * * @param {string} handle * @param {CaseManagementModels.AssociationsRequestDTO} associationsRequestDto * @param {{ ifMatch: string }} params * @return {*} {Promise<CaseManagementModels.CaseSuccessResponseStatus>} * @memberof CaseManagementClient */ UpdateAssociations(handle, associationsRequestDto, params) { return __awaiter(this, void 0, void 0, function* () { const parameters = params || {}; const { ifMatch } = parameters; const result = yield this.HttpAction({ verb: "PATCH", body: associationsRequestDto, gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/cases/${handle}/associations`, additionalHeaders: { "If-Match": ifMatch }, }); return result; }); } /** * Partial update externalSystems for given case handle * * @param {string} handle * @param {CaseManagementModels.ExternalSystemsRequestDTO} externalSystemsRequestDto * @param {{ ifMatch: string }} params * @return {*} {Promise<CaseManagementModels.CaseSuccessResponseStatus>} * @memberof CaseManagementClient */ UpdateExternalSystems(handle, externalSystemsRequestDto, params) { return __awaiter(this, void 0, void 0, function* () { const parameters = params || {}; const { ifMatch } = parameters; const result = yield this.HttpAction({ verb: "PATCH", body: externalSystemsRequestDto, gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/cases/${handle}/externalsystems`, additionalHeaders: { "If-Match": ifMatch }, }); return result; }); } /** * Partial update tags for given case handle * * @param {string} handle * @param {CaseManagementModels.TagsRequestDTO} tags * @param {{ ifMatch: string }} params * @return {*} {Promise<CaseManagementModels.CaseSuccessResponseStatus>} * @memberof CaseManagementClient */ UpdateTags(handle, tags, params) { return __awaiter(this, void 0, void 0, function* () { const parameters = params || {}; const { ifMatch } = parameters; const result = yield this.HttpAction({ verb: "PATCH", body: tags, gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/cases/${handle}/tags`, additionalHeaders: { "If-Match": ifMatch }, }); return result; }); } /** * Create comment for given case handle * * @param {string} handle * @param {CaseManagementModels.CaseCommentsRequestDTO} comment * @return {*} {Promise<CaseManagementModels.CaseSuccessResponseStatus>} * @memberof CaseManagementClient */ CreateComment(handle, comment) { return __awaiter(this, void 0, void 0, function* () { const result = yield this.HttpAction({ verb: "POST", body: comment, gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/cases/${handle}/comments`, }); return result; }); } /** * Get list of case comments for given case handle * * @param {string} handle * @param {{ * page?: number; * size?: number; * sort?: string; * filter?: string; * }} [params] * @return {*} {Promise<CaseManagementModels.CaseCommentsListResponse>} * @memberof CaseManagementClient */ GetCaseComents(handle, params) { return __awaiter(this, void 0, void 0, function* () { const parameters = params || {}; const { page, size, sort, filter } = parameters; const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/cases/${handle}/comments?${(0, utils_1.toQueryString)({ page, size, sort, filter })}`, }); return result; }); } /** * Partial update comment for given case handle * * @param {string} handle * @param {string} id * @param {CaseManagementModels.CaseCommentsRequestDTO} comment * @param {{ ifMatch: string }} params * @return {*} {Promise<CaseManagementModels.CaseSuccessResponseStatus>} * @memberof CaseManagementClient */ UpdateComment(handle, id, comment, params) { return __awaiter(this, void 0, void 0, function* () { const parameters = params || {}; const { ifMatch } = parameters; const result = yield this.HttpAction({ verb: "PATCH", body: comment, gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/cases/${handle}/comments/${id}`, additionalHeaders: { "If-Match": ifMatch }, }); return result; }); } /** * Delete comment * * @param {string} handle * @param {string} id * @param {{ ifMatch: string }} params * @memberof CaseManagementClient */ DeleteComment(handle, id, params) { return __awaiter(this, void 0, void 0, function* () { const parameters = params || {}; const { ifMatch } = parameters; yield this.HttpAction({ verb: "DELETE", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/cases/${handle}/comments/${id}`, additionalHeaders: { "If-Match": ifMatch }, noResponse: true, }); }); } } exports.CaseManagementClient = CaseManagementClient; //# sourceMappingURL=cases.js.map