/**
* File Auto-Generated by the RICADO Gen 4 PHP API Project
*
* Do Not Edit this File Manually!
*/
import RequestHelper from '../../../RequestHelper';
import RejectBinScaleModel from '../../../Models/Packhouse/Site/RejectBinScaleModel';
/**
* Controller Class for Reject Bin Scales
*
* @class
*/
class RejectBinScaleController
{
/**
* Retrieve a Reject Bin Scale [GET /packhouse/sites/{siteId}/reject-bin-scales/{id}]
*
* @static
* @public
* @param {number} siteId The Site ID
* @param {string} id The Reject Bin Scale ID
* @return {Promise<RejectBinScaleModel>}
*/
static getOne(siteId, id)
{
return new Promise((resolve, reject) => {
RequestHelper.getRequest(`/packhouse/sites/${siteId}/reject-bin-scales/${id}`)
.then((result) => {
let resolveValue = (function(){
return RejectBinScaleModel.fromJSON(result, siteId);
}());
resolve(resolveValue);
})
.catch(error => reject(error));
});
}
/**
* Update a Reject Bin Scale [PATCH /packhouse/sites/{siteId}/reject-bin-scales/{id}]
*
* @static
* @public
* @param {number} siteId The Site ID
* @param {string} id The Reject Bin Scale ID
* @param {RejectBinScaleController.UpdateData} updateData The Reject Bin Scale Update Data
* @return {Promise<RejectBinScaleModel>}
*/
static update(siteId, id, updateData)
{
return new Promise((resolve, reject) => {
RequestHelper.patchRequest(`/packhouse/sites/${siteId}/reject-bin-scales/${id}`, updateData)
.then((result) => {
let resolveValue = (function(){
return RejectBinScaleModel.fromJSON(result, siteId);
}());
resolve(resolveValue);
})
.catch(error => reject(error));
});
}
/**
* Delete a Reject Bin Scale [DELETE /packhouse/sites/{siteId}/reject-bin-scales/{id}]
*
* @static
* @public
* @param {number} siteId The Site ID
* @param {string} id The Reject Bin Scale ID
* @return {Promise<boolean>}
*/
static delete(siteId, id)
{
return new Promise((resolve, reject) => {
RequestHelper.deleteRequest(`/packhouse/sites/${siteId}/reject-bin-scales/${id}`)
.then((result) => {
resolve(result ?? true);
})
.catch(error => reject(error));
});
}
/**
* List all Reject Bin Scales [GET /packhouse/sites/{siteId}/reject-bin-scales]
*
* @static
* @public
* @param {number} siteId The Site ID
* @param {RejectBinScaleController.GetAllQueryParameters} [queryParameters] The Optional Query Parameters
* @return {Promise<RejectBinScaleModel[]>}
*/
static getAll(siteId, queryParameters = {})
{
return new Promise((resolve, reject) => {
RequestHelper.getRequest(`/packhouse/sites/${siteId}/reject-bin-scales`, queryParameters)
.then((result) => {
let resolveValue = (function(){
if(Array.isArray(result) !== true)
{
return [];
}
return result.map((resultItem) => {
return (function(){
return RejectBinScaleModel.fromJSON(resultItem, siteId);
}());
});
}());
resolve(resolveValue);
})
.catch(error => reject(error));
});
}
/**
* Create a Reject Bin Scale [POST /packhouse/sites/{siteId}/reject-bin-scales]
*
* @static
* @public
* @param {number} siteId The Site ID
* @param {RejectBinScaleController.CreateData} createData The Reject Bin Scale Create Data
* @return {Promise<RejectBinScaleModel>}
*/
static create(siteId, createData)
{
return new Promise((resolve, reject) => {
RequestHelper.postRequest(`/packhouse/sites/${siteId}/reject-bin-scales`, createData)
.then((result) => {
let resolveValue = (function(){
return RejectBinScaleModel.fromJSON(result, siteId);
}());
resolve(resolveValue);
})
.catch(error => reject(error));
});
}
}
export default RejectBinScaleController;
/**
* The Optional Query Parameters for the getAll Function
*
* @typedef {Object} RejectBinScaleController.GetAllQueryParameters
* @property {?number} [rtuId] The RTU this Reject Bin Scale belongs to
* @property {string} [name] The Name of this Reject Bin Scale
* @property {string} [packingLineId] The Packing Line that owns this Reject Bin Scale
* @property {?string} [packrunSourceId] The Permanent Object that provides the Next Packrun for this Reject Bin Scale
* @property {?number} [packrunGroup] The Packrun Group this Reject Bin Scale is a part of
* @memberof Controllers.Packhouse.Site
*/
/**
* The Create Data for a Reject Bin Scale
*
* @typedef {Object} RejectBinScaleController.CreateData
* @property {?number} [rtuId] The RTU this Reject Bin Scale belongs to
* @property {string} name The Name of this Reject Bin Scale
* @property {{weighButton: ?number, packrunButton: ?number, manualInterventionButton: ?number, clearIndicator: ?number, busyIndicator: ?number, packrunIndicator: ?number, manualInterventionIndicator: ?number, sirenControl: ?number, scaleTareRequest: ?number, scaleClearTareRequest: ?number, scaleZeroRequest: ?number, scaleStableStatus: number, scaleWeight: ?number, scaleNetWeight: ?number, scaleGrossWeight: ?number, scaleTareWeight: ?number, targetGrossWeight: ?number, currentLiveWeight: ?number, startLiveWeighingRequest: ?number, finishLiveWeighingRequest: ?number, fruitDeliveryActive: ?number, status: number, currentPackrunId: number, nextPackrunId: number, currentPackrunName: number, nextPackrunName: number, incorrectOperationStatus: ?number, currentPackrunIncorrectOperationsCount: ?number, totalIncorrectOperationsCount: ?number, manualInterventionStatus: ?number, currentPackrunManualInterventionsCount: ?number, totalManualInterventionsCount: ?number, currentPackrunBinsWeighedCount: number, totalBinsWeighedCount: number}} points The Points used by this Reject Bin Scale
* @property {string} packingLineId The Packing Line that owns this Reject Bin Scale
* @property {?string} [packrunSourceId] The Permanent Object that provides the Next Packrun for this Reject Bin Scale
* @property {?number} [packrunGroup] The Packrun Group this Reject Bin Scale is a part of
* @property {Array<RejectBinScaleController.SortingTableSource|RejectBinScaleController.BeltSource|RejectBinScaleController.SizerOutletSource>} [sources] An Array of Sources that deliver Fruit to this Reject Bin Scale
* @property {?{delay: ?number}} [autoPackrunChange] The Auto Packrun Change Configuration for this Reject Bin Scale
* @property {?boolean} [supportsLiveWeighing] Whether this Reject Bin Scale supports Live Weighing
* @property {?number} [autoWeighingStartThreshold] The Minimum Weight Change Required to Automatically Start Live Weighing
* @property {?number} [autoWeighingStartDelay] The Delay in Milliseconds before Auto Live Weighing would Start
* @property {?number} [autoWeighingFinishThreshold] The Minimum Weight Change Required to Automatically Finish Live Weighing
* @property {?number} [autoWeighingFinishDelay] The Delay in Milliseconds before Auto Live Weighing would Finish
* @property {?boolean} [autoWeighingFinishAtGrossTarget] Whether Live Weighing should be Automatically Finished when the Target Gross Weight is Met
* @property {?number} [manualInterventionMaximumDuration] The Maximum Duration in Milliseconds before a Manual Intervention would end
* @property {?number} [liveWeighingIncreaseTolerance] The Maximum Weight Increase allowed within a single Live Weighing Update Interval
* @property {?number} [liveWeighingDecreaseTolerance] The Maximum Weight Decrease allowed within a single Live Weighing Update Interval
* @property {?number} [liveWeighingUpdateInterval] The Interval in Milliseconds between Live Weighing Updates
* @property {?boolean} [liveWeighingUsesStableStatus] Whether the Loadcell Stable Status is used to ignore Changes during Live Weighing
* @property {?number} [incorrectOperationTolerance] The Maximum Weight Change allowed while Live Weighing before an Incorrect Operation is Logged
* @property {?RejectBinScaleController.FreshPackBinScaleIntegration} [freshPackIntegration] The FreshPack Integration Configuration for this Reject Bin Scale
* @memberof Controllers.Packhouse.Site
*/
/**
* The Update Data for a Reject Bin Scale
*
* @typedef {Object} RejectBinScaleController.UpdateData
* @property {string} [name] The Name of this Reject Bin Scale
* @property {{weighButton: ?number, packrunButton: ?number, manualInterventionButton: ?number, clearIndicator: ?number, busyIndicator: ?number, packrunIndicator: ?number, manualInterventionIndicator: ?number, sirenControl: ?number, scaleTareRequest: ?number, scaleClearTareRequest: ?number, scaleZeroRequest: ?number, scaleStableStatus: number, scaleWeight: ?number, scaleNetWeight: ?number, scaleGrossWeight: ?number, scaleTareWeight: ?number, targetGrossWeight: ?number, currentLiveWeight: ?number, startLiveWeighingRequest: ?number, finishLiveWeighingRequest: ?number, fruitDeliveryActive: ?number, status: number, currentPackrunId: number, nextPackrunId: number, currentPackrunName: number, nextPackrunName: number, incorrectOperationStatus: ?number, currentPackrunIncorrectOperationsCount: ?number, totalIncorrectOperationsCount: ?number, manualInterventionStatus: ?number, currentPackrunManualInterventionsCount: ?number, totalManualInterventionsCount: ?number, currentPackrunBinsWeighedCount: number, totalBinsWeighedCount: number}} [points] The Points used by this Reject Bin Scale
* @property {string} [packingLineId] The Packing Line that owns this Reject Bin Scale
* @property {?string} [packrunSourceId] The Permanent Object that provides the Next Packrun for this Reject Bin Scale
* @property {?number} [packrunGroup] The Packrun Group this Reject Bin Scale is a part of
* @property {Array<RejectBinScaleController.SortingTableSource|RejectBinScaleController.BeltSource|RejectBinScaleController.SizerOutletSource>} [sources] An Array of Sources that deliver Fruit to this Reject Bin Scale
* @property {?{delay: ?number}} [autoPackrunChange] The Auto Packrun Change Configuration for this Reject Bin Scale
* @property {?boolean} [supportsLiveWeighing] Whether this Reject Bin Scale supports Live Weighing
* @property {?number} [autoWeighingStartThreshold] The Minimum Weight Change Required to Automatically Start Live Weighing
* @property {?number} [autoWeighingStartDelay] The Delay in Milliseconds before Auto Live Weighing would Start
* @property {?number} [autoWeighingFinishThreshold] The Minimum Weight Change Required to Automatically Finish Live Weighing
* @property {?number} [autoWeighingFinishDelay] The Delay in Milliseconds before Auto Live Weighing would Finish
* @property {?boolean} [autoWeighingFinishAtGrossTarget] Whether Live Weighing should be Automatically Finished when the Target Gross Weight is Met
* @property {?number} [manualInterventionMaximumDuration] The Maximum Duration in Milliseconds before a Manual Intervention would end
* @property {?number} [liveWeighingIncreaseTolerance] The Maximum Weight Increase allowed within a single Live Weighing Update Interval
* @property {?number} [liveWeighingDecreaseTolerance] The Maximum Weight Decrease allowed within a single Live Weighing Update Interval
* @property {?number} [liveWeighingUpdateInterval] The Interval in Milliseconds between Live Weighing Updates
* @property {?boolean} [liveWeighingUsesStableStatus] Whether the Loadcell Stable Status is used to ignore Changes during Live Weighing
* @property {?number} [incorrectOperationTolerance] The Maximum Weight Change allowed while Live Weighing before an Incorrect Operation is Logged
* @property {?RejectBinScaleController.FreshPackBinScaleIntegration} [freshPackIntegration] The FreshPack Integration Configuration for this Reject Bin Scale
* @memberof Controllers.Packhouse.Site
*/
/**
* A **SortingTableSource** Type
*
* @typedef {Object} RejectBinScaleController.SortingTableSource
* @property {string} type Type of this Reject Bin Scale Source
* @property {string} sortingTableId ID of the Sorting Table Object
* @property {string} classType The Default Class Type of this Reject Bin Scale Source
* @property {Array<{varietyId: string, classType: string}>} varietyClassTypes An Array of Varieties and Class Types to override the Default Class Type
* @memberof Controllers.Packhouse.Site
*/
/**
* A **BeltSource** Type
*
* @typedef {Object} RejectBinScaleController.BeltSource
* @property {string} type Type of this Reject Bin Scale Source
* @property {?string} beltName Name of the Belt
* @property {string} classType The Default Class Type of this Reject Bin Scale Source
* @property {Array<{varietyId: string, classType: string}>} varietyClassTypes An Array of Varieties and Class Types to override the Default Class Type
* @memberof Controllers.Packhouse.Site
*/
/**
* A **SizerOutletSource** Type
*
* @typedef {Object} RejectBinScaleController.SizerOutletSource
* @property {string} type Type of this Reject Bin Scale Source
* @property {string} sizerId ID of the Sizer Object
* @property {number} outletNumber Outlet Number of the Sizer Outlet
* @memberof Controllers.Packhouse.Site
*/
/**
* A **FreshPackBinScaleIntegration** Type
*
* @typedef {Object} RejectBinScaleController.FreshPackBinScaleIntegration
* @property {Object} points The Points used by this FreshPack Bin Scale Integration
* @property {boolean} enabled Whether this FreshPack Bin Scale Integration is Enabled
* @property {?number} materialGroupId The FreshPack Material Group ID to be used for Multi-Grower Bins from this Reject Bin Scale
* @property {number} binTypeId The FreshPack Bin Type ID to be used for Multi-Grower Bins from this Reject Bin Scale
* @property {?number} printerGroupId The FreshPack Printer Group ID to be used when Printing Multi-Grower Bin Cards for this Reject Bin Scale
* @property {boolean} binCardPrintingEnabled Whether Bin Card Printing is Enabled
* @property {boolean} [useWindowsDriverApi] Whether Bin Card Printing should use the Specialized FreshPack Windows Driver API
* @memberof Controllers.Packhouse.Site
*/
source