/**
* 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 Reemoon Sizer Packrun Summary
*
* @class
* @hideconstructor
* @extends BaseModel
*/
class ReemoonSizerPackrunSummaryModel extends BaseModel
{
/**
* ReemoonSizerPackrunSummaryModel Constructor
*
* @protected
* @param {number} siteId The Site ID associated with this Reemoon Sizer Packrun Summary
*/
constructor(siteId)
{
super();
/**
* The Reemoon Sizer Packrun Summary ID
*
* @type {string}
* @public
*/
this.id = "";
/**
* The Reemoon Sizer ID this Summary is associated with
*
* @type {string}
* @public
*/
this.reemoonSizerId = "";
/**
* The Packrun ID this Summary is associated with
*
* @type {string}
* @public
*/
this.packrunId = "";
/**
* When this Summary was Created
*
* @type {Date}
* @public
*/
this.createdTimestamp = new Date();
/**
* The Time Batch this Summary is associated with
*
* @type {?string}
* @public
*/
this.timeBatchId = null;
/**
* An Array of Packrun Summary Data Objects for each Outlet
*
* @type {Array<{name: string, type: string, number: number, totals: Array<{classType: ?string, fruitSize: string, packType: ?string, weight: number, fruitCount: number, packCount: ?number}>}>}
* @public
*/
this.outletSummaries = [];
/**
* An Array that contains the Products initially Assigned to each Outlet
*
* @type {Array<{outletNumber: number, productId: ?number, productName: string}>}
* @public
*/
this.initialOutletProducts = [];
/**
* Whether the Reemoon Sizer Packrun Summary has been deleted
*
* @type {boolean}
* @public
*/
this.deleted = false;
/**
* When the Reemoon Sizer Packrun Summary was last updated
*
* @type {Date}
* @public
*/
this.updateTimestamp = new Date();
/**
* The Site ID associated with this Reemoon Sizer Packrun Summary
*
* @type {number}
* @public
*/
this.siteId = siteId;
}
/**
* Create a new **ReemoonSizerPackrunSummaryModel** 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 Reemoon Sizer Packrun Summary
* @return {ReemoonSizerPackrunSummaryModel}
*/
static fromJSON(json, siteId)
{
let model = new ReemoonSizerPackrunSummaryModel(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('reemoonSizerId' in jsonObject)
{
model.reemoonSizerId = (function(){
if(typeof jsonObject['reemoonSizerId'] !== 'string')
{
return String(jsonObject['reemoonSizerId']);
}
return jsonObject['reemoonSizerId'];
}());
}
if('packrunId' in jsonObject)
{
model.packrunId = (function(){
if(typeof jsonObject['packrunId'] !== 'string')
{
return String(jsonObject['packrunId']);
}
return jsonObject['packrunId'];
}());
}
if('createdTimestamp' in jsonObject)
{
model.createdTimestamp = (function(){
if(typeof jsonObject['createdTimestamp'] !== 'string')
{
return new Date(String(jsonObject['createdTimestamp']));
}
return new Date(jsonObject['createdTimestamp']);
}());
}
if('timeBatchId' in jsonObject)
{
model.timeBatchId = (function(){
if(jsonObject['timeBatchId'] === null)
{
return null;
}
if(typeof jsonObject['timeBatchId'] !== 'string')
{
return String(jsonObject['timeBatchId']);
}
return jsonObject['timeBatchId'];
}());
}
if('outletSummaries' in jsonObject)
{
model.outletSummaries = (function(){
if(Array.isArray(jsonObject['outletSummaries']) !== true)
{
return [];
}
return jsonObject['outletSummaries'].map((outletSummariesItem) => {
return (function(){
let outletSummariesItemObject = {};
if(typeof outletSummariesItem === 'object' && 'name' in outletSummariesItem)
{
outletSummariesItemObject.name = (function(){
if(typeof outletSummariesItem.name !== 'string')
{
return String(outletSummariesItem.name);
}
return outletSummariesItem.name;
}());
}
else
{
outletSummariesItemObject.name = "";
}
if(typeof outletSummariesItem === 'object' && 'type' in outletSummariesItem)
{
outletSummariesItemObject.type = (function(){
if(typeof outletSummariesItem.type !== 'string')
{
return String(outletSummariesItem.type);
}
return outletSummariesItem.type;
}());
}
else
{
outletSummariesItemObject.type = "";
}
if(typeof outletSummariesItem === 'object' && 'number' in outletSummariesItem)
{
outletSummariesItemObject.number = (function(){
if(typeof outletSummariesItem.number !== 'number')
{
return Number.isInteger(Number(outletSummariesItem.number)) ? Number(outletSummariesItem.number) : Math.floor(Number(outletSummariesItem.number));
}
return Number.isInteger(outletSummariesItem.number) ? outletSummariesItem.number : Math.floor(outletSummariesItem.number);
}());
}
else
{
outletSummariesItemObject.number = 0;
}
if(typeof outletSummariesItem === 'object' && 'totals' in outletSummariesItem)
{
outletSummariesItemObject.totals = (function(){
if(Array.isArray(outletSummariesItem.totals) !== true)
{
return [];
}
return outletSummariesItem.totals.map((totalsItem) => {
return (function(){
let totalsItemObject = {};
if(typeof totalsItem === 'object' && 'classType' in totalsItem)
{
totalsItemObject.classType = (function(){
if(totalsItem.classType === null)
{
return null;
}
if(typeof totalsItem.classType !== 'string')
{
return String(totalsItem.classType);
}
return totalsItem.classType;
}());
}
else
{
totalsItemObject.classType = null;
}
if(typeof totalsItem === 'object' && 'fruitSize' in totalsItem)
{
totalsItemObject.fruitSize = (function(){
if(typeof totalsItem.fruitSize !== 'string')
{
return String(totalsItem.fruitSize);
}
return totalsItem.fruitSize;
}());
}
else
{
totalsItemObject.fruitSize = "";
}
if(typeof totalsItem === 'object' && 'packType' in totalsItem)
{
totalsItemObject.packType = (function(){
if(totalsItem.packType === null)
{
return null;
}
if(typeof totalsItem.packType !== 'string')
{
return String(totalsItem.packType);
}
return totalsItem.packType;
}());
}
else
{
totalsItemObject.packType = null;
}
if(typeof totalsItem === 'object' && 'weight' in totalsItem)
{
totalsItemObject.weight = (function(){
if(typeof totalsItem.weight !== 'number')
{
return Number(totalsItem.weight);
}
return totalsItem.weight;
}());
}
else
{
totalsItemObject.weight = 0;
}
if(typeof totalsItem === 'object' && 'fruitCount' in totalsItem)
{
totalsItemObject.fruitCount = (function(){
if(typeof totalsItem.fruitCount !== 'number')
{
return Number.isInteger(Number(totalsItem.fruitCount)) ? Number(totalsItem.fruitCount) : Math.floor(Number(totalsItem.fruitCount));
}
return Number.isInteger(totalsItem.fruitCount) ? totalsItem.fruitCount : Math.floor(totalsItem.fruitCount);
}());
}
else
{
totalsItemObject.fruitCount = 0;
}
if(typeof totalsItem === 'object' && 'packCount' in totalsItem)
{
totalsItemObject.packCount = (function(){
if(totalsItem.packCount === null)
{
return null;
}
if(typeof totalsItem.packCount !== 'number')
{
return Number(totalsItem.packCount);
}
return totalsItem.packCount;
}());
}
else
{
totalsItemObject.packCount = null;
}
return totalsItemObject;
}());
});
}());
}
else
{
outletSummariesItemObject.totals = [];
}
return outletSummariesItemObject;
}());
});
}());
}
if('initialOutletProducts' in jsonObject)
{
model.initialOutletProducts = (function(){
if(Array.isArray(jsonObject['initialOutletProducts']) !== true)
{
return [];
}
return jsonObject['initialOutletProducts'].map((initialOutletProductsItem) => {
return (function(){
let initialOutletProductsItemObject = {};
if(typeof initialOutletProductsItem === 'object' && 'outletNumber' in initialOutletProductsItem)
{
initialOutletProductsItemObject.outletNumber = (function(){
if(typeof initialOutletProductsItem.outletNumber !== 'number')
{
return Number.isInteger(Number(initialOutletProductsItem.outletNumber)) ? Number(initialOutletProductsItem.outletNumber) : Math.floor(Number(initialOutletProductsItem.outletNumber));
}
return Number.isInteger(initialOutletProductsItem.outletNumber) ? initialOutletProductsItem.outletNumber : Math.floor(initialOutletProductsItem.outletNumber);
}());
}
else
{
initialOutletProductsItemObject.outletNumber = 0;
}
if(typeof initialOutletProductsItem === 'object' && 'productId' in initialOutletProductsItem)
{
initialOutletProductsItemObject.productId = (function(){
if(initialOutletProductsItem.productId === null)
{
return null;
}
if(typeof initialOutletProductsItem.productId !== 'number')
{
return Number.isInteger(Number(initialOutletProductsItem.productId)) ? Number(initialOutletProductsItem.productId) : Math.floor(Number(initialOutletProductsItem.productId));
}
return Number.isInteger(initialOutletProductsItem.productId) ? initialOutletProductsItem.productId : Math.floor(initialOutletProductsItem.productId);
}());
}
else
{
initialOutletProductsItemObject.productId = null;
}
if(typeof initialOutletProductsItem === 'object' && 'productName' in initialOutletProductsItem)
{
initialOutletProductsItemObject.productName = (function(){
if(typeof initialOutletProductsItem.productName !== 'string')
{
return String(initialOutletProductsItem.productName);
}
return initialOutletProductsItem.productName;
}());
}
else
{
initialOutletProductsItemObject.productName = "";
}
return initialOutletProductsItemObject;
}());
});
}());
}
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 ReemoonSizerPackrunSummaryModel;
source