/**
* File Auto-Generated by the RICADO Gen 4 PHP API Project
*
* Do Not Edit this File Manually!
*/
import BaseModel from '../../../Models/BaseModel';
/**
* Model Class for a Shift Quality Summary
*
* @class
* @hideconstructor
* @extends BaseModel
*/
class ShiftQualitySummaryModel extends BaseModel
{
/**
* ShiftQualitySummaryModel Constructor
*
* @protected
* @param {number} siteId The Site ID associated with this Shift Quality Summary
*/
constructor(siteId)
{
super();
/**
* The Shift Quality Summary ID
*
* @type {string}
* @public
*/
this.id = "";
/**
* The Packing Line ID this Quality Summary is associated with
*
* @type {string}
* @public
*/
this.packingLineId = "";
/**
* The Shift ID this Quality Summary is asssociated with
*
* @type {string}
* @public
*/
this.shiftId = "";
/**
* When this Quality Summary was Created
*
* @type {Date}
* @public
*/
this.createdTimestamp = new Date();
/**
* When this Quality Summary was Published
*
* @type {?Date}
* @public
*/
this.publishTimestamp = null;
/**
* The User ID of the Quality Manager for this Summary
*
* @type {string}
* @public
*/
this.qualityManagerUserId = "";
/**
* The Name of the Quality Manager for this Summary
*
* @type {string}
* @public
*/
this.qualityManagerName = "";
/**
* An Array of Accuracy Results for this Summary
*
* @type {Array<{type: string, value: number}>}
* @public
*/
this.accuracyResults = [];
/**
* An Array of Audit Results for this Summary
*
* @type {Array<{type: string, value: number}>}
* @public
*/
this.auditResults = [];
/**
* An Array of Packrun Results for this Summary
*
* @type {Array<{packrunId: string, packrunName: string, minorPackingDefects: number, majorPackingDefects: number, softs: number, cuts: number, rots: number, softsLineAverageSampleSize: ?number, softsLineAverageValue: ?number, exportFruitInClass2: ?number, exportFruitInLocalMarket: ?number, exportFruitInWaste: ?number}>}
* @public
*/
this.packrunResults = [];
/**
* An Optional Rating between 1 and 10 on how Satisfied the Quality Manager was with this Shift
*
* @type {?number}
* @public
*/
this.satisfactionRating = null;
/**
* The Status of this Quality Summary
*
* @type {string}
* @public
*/
this.status = "";
/**
* Whether the Shift Quality Summary has been deleted
*
* @type {boolean}
* @public
*/
this.deleted = false;
/**
* When the Shift Quality Summary was last updated
*
* @type {Date}
* @public
*/
this.updateTimestamp = new Date();
/**
* The Site ID associated with this Shift Quality Summary
*
* @type {number}
* @public
*/
this.siteId = siteId;
}
/**
* Create a new **ShiftQualitySummaryModel** from a JSON Object or JSON String
*
* @static
* @public
* @param {Object<string, any>|string} json A JSON Object or JSON String
* @param {number} siteId The Site ID associated with this Shift Quality Summary
* @return {ShiftQualitySummaryModel}
*/
static fromJSON(json, siteId)
{
let model = new ShiftQualitySummaryModel(siteId);
/**
* The JSON Object
*
* @type {Object<string, any>}
*/
let jsonObject = {};
if(typeof json === 'string')
{
jsonObject = JSON.parse(json);
}
else if(typeof json === 'object')
{
jsonObject = json;
}
if('id' in jsonObject)
{
model.id = (function(){
if(typeof jsonObject['id'] !== 'string')
{
return String(jsonObject['id']);
}
return jsonObject['id'];
}());
}
if('packingLineId' in jsonObject)
{
model.packingLineId = (function(){
if(typeof jsonObject['packingLineId'] !== 'string')
{
return String(jsonObject['packingLineId']);
}
return jsonObject['packingLineId'];
}());
}
if('shiftId' in jsonObject)
{
model.shiftId = (function(){
if(typeof jsonObject['shiftId'] !== 'string')
{
return String(jsonObject['shiftId']);
}
return jsonObject['shiftId'];
}());
}
if('createdTimestamp' in jsonObject)
{
model.createdTimestamp = (function(){
if(typeof jsonObject['createdTimestamp'] !== 'string')
{
return new Date(String(jsonObject['createdTimestamp']));
}
return new Date(jsonObject['createdTimestamp']);
}());
}
if('publishTimestamp' in jsonObject)
{
model.publishTimestamp = (function(){
if(jsonObject['publishTimestamp'] === null)
{
return null;
}
if(typeof jsonObject['publishTimestamp'] !== 'string')
{
return new Date(String(jsonObject['publishTimestamp']));
}
return new Date(jsonObject['publishTimestamp']);
}());
}
if('qualityManagerUserId' in jsonObject)
{
model.qualityManagerUserId = (function(){
if(typeof jsonObject['qualityManagerUserId'] !== 'string')
{
return String(jsonObject['qualityManagerUserId']);
}
return jsonObject['qualityManagerUserId'];
}());
}
if('qualityManagerName' in jsonObject)
{
model.qualityManagerName = (function(){
if(typeof jsonObject['qualityManagerName'] !== 'string')
{
return String(jsonObject['qualityManagerName']);
}
return jsonObject['qualityManagerName'];
}());
}
if('accuracyResults' in jsonObject)
{
model.accuracyResults = (function(){
if(Array.isArray(jsonObject['accuracyResults']) !== true)
{
return [];
}
return jsonObject['accuracyResults'].map((accuracyResultsItem) => {
return (function(){
let accuracyResultsItemObject = {};
if(typeof accuracyResultsItem === 'object' && 'type' in accuracyResultsItem)
{
accuracyResultsItemObject.type = (function(){
if(typeof accuracyResultsItem.type !== 'string')
{
return String(accuracyResultsItem.type);
}
return accuracyResultsItem.type;
}());
}
else
{
accuracyResultsItemObject.type = "";
}
if(typeof accuracyResultsItem === 'object' && 'value' in accuracyResultsItem)
{
accuracyResultsItemObject.value = (function(){
if(typeof accuracyResultsItem.value !== 'number')
{
return Number(accuracyResultsItem.value);
}
return accuracyResultsItem.value;
}());
}
else
{
accuracyResultsItemObject.value = 0;
}
return accuracyResultsItemObject;
}());
});
}());
}
if('auditResults' in jsonObject)
{
model.auditResults = (function(){
if(Array.isArray(jsonObject['auditResults']) !== true)
{
return [];
}
return jsonObject['auditResults'].map((auditResultsItem) => {
return (function(){
let auditResultsItemObject = {};
if(typeof auditResultsItem === 'object' && 'type' in auditResultsItem)
{
auditResultsItemObject.type = (function(){
if(typeof auditResultsItem.type !== 'string')
{
return String(auditResultsItem.type);
}
return auditResultsItem.type;
}());
}
else
{
auditResultsItemObject.type = "";
}
if(typeof auditResultsItem === 'object' && 'value' in auditResultsItem)
{
auditResultsItemObject.value = (function(){
if(typeof auditResultsItem.value !== 'number')
{
return Number(auditResultsItem.value);
}
return auditResultsItem.value;
}());
}
else
{
auditResultsItemObject.value = 0;
}
return auditResultsItemObject;
}());
});
}());
}
if('packrunResults' in jsonObject)
{
model.packrunResults = (function(){
if(Array.isArray(jsonObject['packrunResults']) !== true)
{
return [];
}
return jsonObject['packrunResults'].map((packrunResultsItem) => {
return (function(){
let packrunResultsItemObject = {};
if(typeof packrunResultsItem === 'object' && 'packrunId' in packrunResultsItem)
{
packrunResultsItemObject.packrunId = (function(){
if(typeof packrunResultsItem.packrunId !== 'string')
{
return String(packrunResultsItem.packrunId);
}
return packrunResultsItem.packrunId;
}());
}
else
{
packrunResultsItemObject.packrunId = "";
}
if(typeof packrunResultsItem === 'object' && 'packrunName' in packrunResultsItem)
{
packrunResultsItemObject.packrunName = (function(){
if(typeof packrunResultsItem.packrunName !== 'string')
{
return String(packrunResultsItem.packrunName);
}
return packrunResultsItem.packrunName;
}());
}
else
{
packrunResultsItemObject.packrunName = "";
}
if(typeof packrunResultsItem === 'object' && 'minorPackingDefects' in packrunResultsItem)
{
packrunResultsItemObject.minorPackingDefects = (function(){
if(typeof packrunResultsItem.minorPackingDefects !== 'number')
{
return Number(packrunResultsItem.minorPackingDefects);
}
return packrunResultsItem.minorPackingDefects;
}());
}
else
{
packrunResultsItemObject.minorPackingDefects = 0;
}
if(typeof packrunResultsItem === 'object' && 'majorPackingDefects' in packrunResultsItem)
{
packrunResultsItemObject.majorPackingDefects = (function(){
if(typeof packrunResultsItem.majorPackingDefects !== 'number')
{
return Number(packrunResultsItem.majorPackingDefects);
}
return packrunResultsItem.majorPackingDefects;
}());
}
else
{
packrunResultsItemObject.majorPackingDefects = 0;
}
if(typeof packrunResultsItem === 'object' && 'softs' in packrunResultsItem)
{
packrunResultsItemObject.softs = (function(){
if(typeof packrunResultsItem.softs !== 'number')
{
return Number(packrunResultsItem.softs);
}
return packrunResultsItem.softs;
}());
}
else
{
packrunResultsItemObject.softs = 0;
}
if(typeof packrunResultsItem === 'object' && 'cuts' in packrunResultsItem)
{
packrunResultsItemObject.cuts = (function(){
if(typeof packrunResultsItem.cuts !== 'number')
{
return Number(packrunResultsItem.cuts);
}
return packrunResultsItem.cuts;
}());
}
else
{
packrunResultsItemObject.cuts = 0;
}
if(typeof packrunResultsItem === 'object' && 'rots' in packrunResultsItem)
{
packrunResultsItemObject.rots = (function(){
if(typeof packrunResultsItem.rots !== 'number')
{
return Number(packrunResultsItem.rots);
}
return packrunResultsItem.rots;
}());
}
else
{
packrunResultsItemObject.rots = 0;
}
if(typeof packrunResultsItem === 'object' && 'softsLineAverageSampleSize' in packrunResultsItem)
{
packrunResultsItemObject.softsLineAverageSampleSize = (function(){
if(packrunResultsItem.softsLineAverageSampleSize === null)
{
return null;
}
if(typeof packrunResultsItem.softsLineAverageSampleSize !== 'number')
{
return Number.isInteger(Number(packrunResultsItem.softsLineAverageSampleSize)) ? Number(packrunResultsItem.softsLineAverageSampleSize) : Math.floor(Number(packrunResultsItem.softsLineAverageSampleSize));
}
return Number.isInteger(packrunResultsItem.softsLineAverageSampleSize) ? packrunResultsItem.softsLineAverageSampleSize : Math.floor(packrunResultsItem.softsLineAverageSampleSize);
}());
}
else
{
packrunResultsItemObject.softsLineAverageSampleSize = null;
}
if(typeof packrunResultsItem === 'object' && 'softsLineAverageValue' in packrunResultsItem)
{
packrunResultsItemObject.softsLineAverageValue = (function(){
if(packrunResultsItem.softsLineAverageValue === null)
{
return null;
}
if(typeof packrunResultsItem.softsLineAverageValue !== 'number')
{
return Number(packrunResultsItem.softsLineAverageValue);
}
return packrunResultsItem.softsLineAverageValue;
}());
}
else
{
packrunResultsItemObject.softsLineAverageValue = null;
}
if(typeof packrunResultsItem === 'object' && 'exportFruitInClass2' in packrunResultsItem)
{
packrunResultsItemObject.exportFruitInClass2 = (function(){
if(packrunResultsItem.exportFruitInClass2 === null)
{
return null;
}
if(typeof packrunResultsItem.exportFruitInClass2 !== 'number')
{
return Number(packrunResultsItem.exportFruitInClass2);
}
return packrunResultsItem.exportFruitInClass2;
}());
}
else
{
packrunResultsItemObject.exportFruitInClass2 = null;
}
if(typeof packrunResultsItem === 'object' && 'exportFruitInLocalMarket' in packrunResultsItem)
{
packrunResultsItemObject.exportFruitInLocalMarket = (function(){
if(packrunResultsItem.exportFruitInLocalMarket === null)
{
return null;
}
if(typeof packrunResultsItem.exportFruitInLocalMarket !== 'number')
{
return Number(packrunResultsItem.exportFruitInLocalMarket);
}
return packrunResultsItem.exportFruitInLocalMarket;
}());
}
else
{
packrunResultsItemObject.exportFruitInLocalMarket = null;
}
if(typeof packrunResultsItem === 'object' && 'exportFruitInWaste' in packrunResultsItem)
{
packrunResultsItemObject.exportFruitInWaste = (function(){
if(packrunResultsItem.exportFruitInWaste === null)
{
return null;
}
if(typeof packrunResultsItem.exportFruitInWaste !== 'number')
{
return Number(packrunResultsItem.exportFruitInWaste);
}
return packrunResultsItem.exportFruitInWaste;
}());
}
else
{
packrunResultsItemObject.exportFruitInWaste = null;
}
return packrunResultsItemObject;
}());
});
}());
}
if('satisfactionRating' in jsonObject)
{
model.satisfactionRating = (function(){
if(jsonObject['satisfactionRating'] === null)
{
return null;
}
if(typeof jsonObject['satisfactionRating'] !== 'number')
{
return Number.isInteger(Number(jsonObject['satisfactionRating'])) ? Number(jsonObject['satisfactionRating']) : Math.floor(Number(jsonObject['satisfactionRating']));
}
return Number.isInteger(jsonObject['satisfactionRating']) ? jsonObject['satisfactionRating'] : Math.floor(jsonObject['satisfactionRating']);
}());
}
if('status' in jsonObject)
{
model.status = (function(){
if(typeof jsonObject['status'] !== 'string')
{
return String(jsonObject['status']);
}
return jsonObject['status'];
}());
}
if('deleted' in jsonObject)
{
model.deleted = (function(){
if(typeof jsonObject['deleted'] !== 'boolean')
{
return Boolean(jsonObject['deleted']);
}
return jsonObject['deleted'];
}());
}
if('updateTimestamp' in jsonObject)
{
model.updateTimestamp = (function(){
if(typeof jsonObject['updateTimestamp'] !== 'string')
{
return new Date(String(jsonObject['updateTimestamp']));
}
return new Date(jsonObject['updateTimestamp']);
}());
}
return model;
}
}
export default ShiftQualitySummaryModel;
source