/**
* File Auto-Generated by the RICADO Gen 4 PHP API Project
*
* Do Not Edit this File Manually!
*/
import RequestHelper from '../../../RequestHelper';
import RackPositionModel from '../../../Models/Lab/Site/RackPositionModel';
/**
* Controller Class for Rack Positions
*
* @class
*/
class RackPositionController
{
/**
* Retrieve a Rack Position [GET /lab/sites/{siteId}/rack-positions/{id}]
*
* @static
* @public
* @param {number} siteId The Site ID
* @param {string} id The Rack Position ID
* @return {Promise<RackPositionModel>}
*/
static getOne(siteId, id)
{
return new Promise((resolve, reject) => {
RequestHelper.getRequest(`/lab/sites/${siteId}/rack-positions/${id}`)
.then((result) => {
let resolveValue = (function(){
return RackPositionModel.fromJSON(result, siteId);
}());
resolve(resolveValue);
})
.catch(error => reject(error));
});
}
/**
* Update a Rack Position [PATCH /lab/sites/{siteId}/rack-positions/{id}]
*
* @static
* @public
* @param {number} siteId The Site ID
* @param {string} id The Rack Position ID
* @param {RackPositionController.UpdateData} updateData The Rack Position Update Data
* @return {Promise<RackPositionModel>}
*/
static update(siteId, id, updateData)
{
return new Promise((resolve, reject) => {
RequestHelper.patchRequest(`/lab/sites/${siteId}/rack-positions/${id}`, updateData)
.then((result) => {
let resolveValue = (function(){
return RackPositionModel.fromJSON(result, siteId);
}());
resolve(resolveValue);
})
.catch(error => reject(error));
});
}
/**
* Delete a Rack Position [DELETE /lab/sites/{siteId}/rack-positions/{id}]
*
* @static
* @public
* @param {number} siteId The Site ID
* @param {string} id The Rack Position ID
* @return {Promise<boolean>}
*/
static delete(siteId, id)
{
return new Promise((resolve, reject) => {
RequestHelper.deleteRequest(`/lab/sites/${siteId}/rack-positions/${id}`)
.then((result) => {
resolve(result ?? true);
})
.catch(error => reject(error));
});
}
/**
* List all Rack Positions [GET /lab/sites/{siteId}/rack-positions]
*
* @static
* @public
* @param {number} siteId The Site ID
* @param {RackPositionController.GetAllQueryParameters} [queryParameters] The Optional Query Parameters
* @return {Promise<RackPositionModel[]>}
*/
static getAll(siteId, queryParameters = {})
{
return new Promise((resolve, reject) => {
RequestHelper.getRequest(`/lab/sites/${siteId}/rack-positions`, queryParameters)
.then((result) => {
let resolveValue = (function(){
if(Array.isArray(result) !== true)
{
return [];
}
return result.map((resultItem) => {
return (function(){
return RackPositionModel.fromJSON(resultItem, siteId);
}());
});
}());
resolve(resolveValue);
})
.catch(error => reject(error));
});
}
/**
* Create a Rack Position [POST /lab/sites/{siteId}/rack-positions]
*
* @static
* @public
* @param {number} siteId The Site ID
* @param {RackPositionController.CreateData} createData The Rack Position Create Data
* @return {Promise<RackPositionModel>}
*/
static create(siteId, createData)
{
return new Promise((resolve, reject) => {
RequestHelper.postRequest(`/lab/sites/${siteId}/rack-positions`, createData)
.then((result) => {
let resolveValue = (function(){
return RackPositionModel.fromJSON(result, siteId);
}());
resolve(resolveValue);
})
.catch(error => reject(error));
});
}
}
export default RackPositionController;
/**
* The Optional Query Parameters for the getAll Function
*
* @typedef {Object} RackPositionController.GetAllQueryParameters
* @property {?number} [rtuId] The RTU this Rack Position belongs to
* @property {string} [name] The Name of this Rack Position
* @property {string} [labId] The Lab that owns this Rack Position
* @property {string} [rackId] The Rack associated with this Rack Position
* @property {number} [verticalLevelIndex] The Index of the Vertical Level in the Rack where this Position resides
* @property {number} [horizontalPositionIndex] The Index of the Horizontal Position in the Rack where this Position resides
* @memberof Controllers.Lab.Site
*/
/**
* The Create Data for a Rack Position
*
* @typedef {Object} RackPositionController.CreateData
* @property {?number} [rtuId] The RTU this Rack Position belongs to
* @property {string} name The Name of this Rack Position
* @property {{pushButton: number, indicatorLight: number, temperature: number, calibrationOffset: number, disabled: number, currentSampleId: number, currentAdditionalSampleIds: number, currentSampleStatus: number, nextSampleId: number, nextAdditionalSampleIds: number, loadCurrentSampleRequest: number, startCurrentSampleRequest: number, finishCurrentSampleRequest: number, unloadCurrentSampleRequest: number, currentSampleTotalDuration: number, currentSampleWarmUpDuration: number, currentSampleWarmUpRateOfChange: number, currentSampleWarmUpWarning: number, currentSampleWarmUpCompleted: number, currentSampleBelowTargetDuration: number, currentSampleAboveTargetDuration: number, currentSampleWithinTargetDuration: number, currentSampleFinishCriteriaMet: number, currentSampleLatestUnloadTimestamp: number}} points The Points used by this Rack Position
* @property {string} labId The Lab that owns this Rack Position
* @property {string} rackId The Rack associated with this Rack Position
* @property {number} verticalLevelIndex The Index of the Vertical Level in the Rack where this Position resides
* @property {number} horizontalPositionIndex The Index of the Horizontal Position in the Rack where this Position resides
* @memberof Controllers.Lab.Site
*/
/**
* The Update Data for a Rack Position
*
* @typedef {Object} RackPositionController.UpdateData
* @property {string} [name] The Name of this Rack Position
* @property {{pushButton: number, indicatorLight: number, temperature: number, calibrationOffset: number, disabled: number, currentSampleId: number, currentAdditionalSampleIds: number, currentSampleStatus: number, nextSampleId: number, nextAdditionalSampleIds: number, loadCurrentSampleRequest: number, startCurrentSampleRequest: number, finishCurrentSampleRequest: number, unloadCurrentSampleRequest: number, currentSampleTotalDuration: number, currentSampleWarmUpDuration: number, currentSampleWarmUpRateOfChange: number, currentSampleWarmUpWarning: number, currentSampleWarmUpCompleted: number, currentSampleBelowTargetDuration: number, currentSampleAboveTargetDuration: number, currentSampleWithinTargetDuration: number, currentSampleFinishCriteriaMet: number, currentSampleLatestUnloadTimestamp: number}} [points] The Points used by this Rack Position
* @property {string} [labId] The Lab that owns this Rack Position
* @property {string} [rackId] The Rack associated with this Rack Position
* @property {number} [verticalLevelIndex] The Index of the Vertical Level in the Rack where this Position resides
* @property {number} [horizontalPositionIndex] The Index of the Horizontal Position in the Rack where this Position resides
* @memberof Controllers.Lab.Site
*/
source