/**
* File Auto-Generated by the RICADO Gen 4 PHP API Project
*
* Do Not Edit this File Manually!
*/
import RequestHelper from '../../../RequestHelper';
import SoftSortBeltModel from '../../../Models/Packhouse/Site/SoftSortBeltModel';
/**
* Controller Class for Soft Sort Belts
*
* @class
*/
class SoftSortBeltController
{
/**
* Retrieve a Soft Sort Belt [GET /packhouse/sites/{siteId}/soft-sort-belts/{id}]
*
* @static
* @public
* @param {number} siteId The Site ID
* @param {string} id The Soft Sort Belt ID
* @return {Promise<SoftSortBeltModel>}
*/
static getOne(siteId, id)
{
return new Promise((resolve, reject) => {
RequestHelper.getRequest(`/packhouse/sites/${siteId}/soft-sort-belts/${id}`)
.then((result) => {
let resolveValue = (function(){
return SoftSortBeltModel.fromJSON(result, siteId);
}());
resolve(resolveValue);
})
.catch(error => reject(error));
});
}
/**
* Update a Soft Sort Belt [PATCH /packhouse/sites/{siteId}/soft-sort-belts/{id}]
*
* @static
* @public
* @param {number} siteId The Site ID
* @param {string} id The Soft Sort Belt ID
* @param {SoftSortBeltController.UpdateData} updateData The Soft Sort Belt Update Data
* @return {Promise<SoftSortBeltModel>}
*/
static update(siteId, id, updateData)
{
return new Promise((resolve, reject) => {
RequestHelper.patchRequest(`/packhouse/sites/${siteId}/soft-sort-belts/${id}`, updateData)
.then((result) => {
let resolveValue = (function(){
return SoftSortBeltModel.fromJSON(result, siteId);
}());
resolve(resolveValue);
})
.catch(error => reject(error));
});
}
/**
* Delete a Soft Sort Belt [DELETE /packhouse/sites/{siteId}/soft-sort-belts/{id}]
*
* @static
* @public
* @param {number} siteId The Site ID
* @param {string} id The Soft Sort Belt ID
* @return {Promise<boolean>}
*/
static delete(siteId, id)
{
return new Promise((resolve, reject) => {
RequestHelper.deleteRequest(`/packhouse/sites/${siteId}/soft-sort-belts/${id}`)
.then((result) => {
resolve(result ?? true);
})
.catch(error => reject(error));
});
}
/**
* Retrieve the Events of a Soft Sort Belt [GET /packhouse/sites/{siteId}/soft-sort-belts/{id}/events]
*
* Retrieves Events for a Single Soft Sort Belt
*
* @static
* @public
* @param {number} siteId The Site ID
* @param {string} id The Soft Sort Belt ID
* @param {SoftSortBeltController.GetOneEventsQueryParameters} [queryParameters] The Optional Query Parameters
* @return {Promise<Array<SoftSortBeltController.SoftSortEventItem>>}
*/
static getOneEvents(siteId, id, queryParameters = {})
{
return new Promise((resolve, reject) => {
RequestHelper.getRequest(`/packhouse/sites/${siteId}/soft-sort-belts/${id}/events`, queryParameters)
.then((result) => {
let resolveValue = (function(){
if(Array.isArray(result) !== true)
{
return [];
}
return result.map((resultItem) => {
return (function(){
let resultItemObject = {};
if(typeof resultItem === 'object' && 'beltId' in resultItem)
{
resultItemObject.beltId = (function(){
if(typeof resultItem.beltId !== 'string')
{
return String(resultItem.beltId);
}
return resultItem.beltId;
}());
}
else
{
resultItemObject.beltId = "";
}
if(typeof resultItem === 'object' && 'packrunId' in resultItem)
{
resultItemObject.packrunId = (function(){
if(typeof resultItem.packrunId !== 'string')
{
return String(resultItem.packrunId);
}
return resultItem.packrunId;
}());
}
else
{
resultItemObject.packrunId = "";
}
if(typeof resultItem === 'object' && 'packrunName' in resultItem)
{
resultItemObject.packrunName = (function(){
if(typeof resultItem.packrunName !== 'string')
{
return String(resultItem.packrunName);
}
return resultItem.packrunName;
}());
}
else
{
resultItemObject.packrunName = "";
}
if(typeof resultItem === 'object' && 'startTimestamp' in resultItem)
{
resultItemObject.startTimestamp = (function(){
if(typeof resultItem.startTimestamp !== 'string')
{
return new Date(String(resultItem.startTimestamp));
}
return new Date(resultItem.startTimestamp);
}());
}
else
{
resultItemObject.startTimestamp = new Date();
}
if(typeof resultItem === 'object' && 'endTimestamp' in resultItem)
{
resultItemObject.endTimestamp = (function(){
if(typeof resultItem.endTimestamp !== 'string')
{
return new Date(String(resultItem.endTimestamp));
}
return new Date(resultItem.endTimestamp);
}());
}
else
{
resultItemObject.endTimestamp = new Date();
}
if(typeof resultItem === 'object' && 'duration' in resultItem)
{
resultItemObject.duration = (function(){
if(typeof resultItem.duration !== 'number')
{
return Number.isInteger(Number(resultItem.duration)) ? Number(resultItem.duration) : Math.floor(Number(resultItem.duration));
}
return Number.isInteger(resultItem.duration) ? resultItem.duration : Math.floor(resultItem.duration);
}());
}
else
{
resultItemObject.duration = 0;
}
return resultItemObject;
}());
});
}());
resolve(resolveValue);
})
.catch(error => reject(error));
});
}
/**
* List all Soft Sort Belts [GET /packhouse/sites/{siteId}/soft-sort-belts]
*
* @static
* @public
* @param {number} siteId The Site ID
* @param {SoftSortBeltController.GetAllQueryParameters} [queryParameters] The Optional Query Parameters
* @return {Promise<SoftSortBeltModel[]>}
*/
static getAll(siteId, queryParameters = {})
{
return new Promise((resolve, reject) => {
RequestHelper.getRequest(`/packhouse/sites/${siteId}/soft-sort-belts`, queryParameters)
.then((result) => {
let resolveValue = (function(){
if(Array.isArray(result) !== true)
{
return [];
}
return result.map((resultItem) => {
return (function(){
return SoftSortBeltModel.fromJSON(resultItem, siteId);
}());
});
}());
resolve(resolveValue);
})
.catch(error => reject(error));
});
}
/**
* Create a Soft Sort Belt [POST /packhouse/sites/{siteId}/soft-sort-belts]
*
* @static
* @public
* @param {number} siteId The Site ID
* @param {SoftSortBeltController.CreateData} createData The Soft Sort Belt Create Data
* @return {Promise<SoftSortBeltModel>}
*/
static create(siteId, createData)
{
return new Promise((resolve, reject) => {
RequestHelper.postRequest(`/packhouse/sites/${siteId}/soft-sort-belts`, createData)
.then((result) => {
let resolveValue = (function(){
return SoftSortBeltModel.fromJSON(result, siteId);
}());
resolve(resolveValue);
})
.catch(error => reject(error));
});
}
/**
* Retrieve the Events of all Soft Sort Belts [GET /packhouse/sites/{siteId}/soft-sort-belts/events]
*
* Retrieves Events for all Soft Sort Belts
*
* @static
* @public
* @param {number} siteId The Site ID
* @param {SoftSortBeltController.GetAllEventsQueryParameters} [queryParameters] The Optional Query Parameters
* @return {Promise<Array<SoftSortBeltController.SoftSortEventItem>>}
*/
static getAllEvents(siteId, queryParameters = {})
{
return new Promise((resolve, reject) => {
RequestHelper.getRequest(`/packhouse/sites/${siteId}/soft-sort-belts/events`, queryParameters)
.then((result) => {
let resolveValue = (function(){
if(Array.isArray(result) !== true)
{
return [];
}
return result.map((resultItem) => {
return (function(){
let resultItemObject = {};
if(typeof resultItem === 'object' && 'beltId' in resultItem)
{
resultItemObject.beltId = (function(){
if(typeof resultItem.beltId !== 'string')
{
return String(resultItem.beltId);
}
return resultItem.beltId;
}());
}
else
{
resultItemObject.beltId = "";
}
if(typeof resultItem === 'object' && 'packrunId' in resultItem)
{
resultItemObject.packrunId = (function(){
if(typeof resultItem.packrunId !== 'string')
{
return String(resultItem.packrunId);
}
return resultItem.packrunId;
}());
}
else
{
resultItemObject.packrunId = "";
}
if(typeof resultItem === 'object' && 'packrunName' in resultItem)
{
resultItemObject.packrunName = (function(){
if(typeof resultItem.packrunName !== 'string')
{
return String(resultItem.packrunName);
}
return resultItem.packrunName;
}());
}
else
{
resultItemObject.packrunName = "";
}
if(typeof resultItem === 'object' && 'startTimestamp' in resultItem)
{
resultItemObject.startTimestamp = (function(){
if(typeof resultItem.startTimestamp !== 'string')
{
return new Date(String(resultItem.startTimestamp));
}
return new Date(resultItem.startTimestamp);
}());
}
else
{
resultItemObject.startTimestamp = new Date();
}
if(typeof resultItem === 'object' && 'endTimestamp' in resultItem)
{
resultItemObject.endTimestamp = (function(){
if(typeof resultItem.endTimestamp !== 'string')
{
return new Date(String(resultItem.endTimestamp));
}
return new Date(resultItem.endTimestamp);
}());
}
else
{
resultItemObject.endTimestamp = new Date();
}
if(typeof resultItem === 'object' && 'duration' in resultItem)
{
resultItemObject.duration = (function(){
if(typeof resultItem.duration !== 'number')
{
return Number.isInteger(Number(resultItem.duration)) ? Number(resultItem.duration) : Math.floor(Number(resultItem.duration));
}
return Number.isInteger(resultItem.duration) ? resultItem.duration : Math.floor(resultItem.duration);
}());
}
else
{
resultItemObject.duration = 0;
}
return resultItemObject;
}());
});
}());
resolve(resolveValue);
})
.catch(error => reject(error));
});
}
}
export default SoftSortBeltController;
/**
* The Optional Query Parameters for the getOneEvents Function
*
* @typedef {Object} SoftSortBeltController.GetOneEventsQueryParameters
* @property {Date} [timestampBegin] The Beginning Timestamp of the Soft-Sort Event Results. Defaults to 24 Hours ago
* @property {Date} [timestampEnd] The End Timestamp of the Soft-Sort Event Results. Defaults to Now
* @memberof Controllers.Packhouse.Site
*/
/**
* The Optional Query Parameters for the getAll Function
*
* @typedef {Object} SoftSortBeltController.GetAllQueryParameters
* @property {?number} [rtuId] The RTU this Soft Sort Belt belongs to
* @property {string} [name] The Name of this Soft Sort Belt
* @property {string} [packingLineId] The Packing Line that owns this Soft Sort Belt
* @memberof Controllers.Packhouse.Site
*/
/**
* The Optional Query Parameters for the getAllEvents Function
*
* @typedef {Object} SoftSortBeltController.GetAllEventsQueryParameters
* @property {string[]} [beltIds] A List of Soft-Sort Belt IDs to Filter by
* @property {Date} [timestampBegin] The Beginning Timestamp of the Soft-Sort Event Results. Defaults to 24 Hours ago
* @property {Date} [timestampEnd] The End Timestamp of the Soft-Sort Event Results. Defaults to Now
* @property {string} [packrunId] A Packrun ID to Filter by. Forces `timestampBegin` and `timestampEnd` to be Ignored
* @memberof Controllers.Packhouse.Site
*/
/**
* The Create Data for a Soft Sort Belt
*
* @typedef {Object} SoftSortBeltController.CreateData
* @property {?number} [rtuId] The RTU this Soft Sort Belt belongs to
* @property {string} name The Name of this Soft Sort Belt
* @property {{runAuto: number, slowMode: ?number, stopMode: number}} points The Points used by this Soft Sort Belt
* @property {string} packingLineId The Packing Line that owns this Soft Sort Belt
* @memberof Controllers.Packhouse.Site
*/
/**
* The Update Data for a Soft Sort Belt
*
* @typedef {Object} SoftSortBeltController.UpdateData
* @property {string} [name] The Name of this Soft Sort Belt
* @property {{runAuto: number, slowMode: ?number, stopMode: number}} [points] The Points used by this Soft Sort Belt
* @property {string} [packingLineId] The Packing Line that owns this Soft Sort Belt
* @memberof Controllers.Packhouse.Site
*/
/**
* A **SoftSortEventItem** Type
*
* @typedef {Object} SoftSortBeltController.SoftSortEventItem
* @property {string} beltId The Soft-Sort Belt ID
* @property {string} packrunId The ID of the associated Packrun
* @property {string} packrunName The Name of the associated Packrun
* @property {Date} startTimestamp When the Event Started
* @property {Date} endTimestamp When the Event Ended
* @property {number} duration The Duration in Seconds of the Event
* @memberof Controllers.Packhouse.Site
*/
source