/**
* 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 FreshPack Bin Lot
*
* @class
* @hideconstructor
* @extends BaseModel
*/
class FreshPackBinLotModel extends BaseModel
{
/**
* FreshPackBinLotModel Constructor
*
* @protected
* @param {number} siteId The Site ID associated with this FreshPack Bin Lot
*/
constructor(siteId)
{
super();
/**
* The FreshPack Bin Lot ID
*
* @type {string}
* @public
*/
this.id = "";
/**
* The Bin Tip ID this Bin Lot is associated with
*
* @type {string}
* @public
*/
this.binTipId = "";
/**
* The Bin Lot Code
*
* @type {string}
* @public
*/
this.binLotCode = "";
/**
* When this Bin Lot was Created
*
* @type {Date}
* @public
*/
this.createdTimestamp = new Date();
/**
* An Array of Packrun IDs associated with this Bin Lot
*
* @type {string[]}
* @public
*/
this.packrunIds = [];
/**
* An Array of Bin Numbers for this Bin Lot
*
* @type {string[]}
* @public
*/
this.binNumbers = [];
/**
* Whether the FreshPack Bin Lot has been deleted
*
* @type {boolean}
* @public
*/
this.deleted = false;
/**
* When the FreshPack Bin Lot was last updated
*
* @type {Date}
* @public
*/
this.updateTimestamp = new Date();
/**
* The Site ID associated with this FreshPack Bin Lot
*
* @type {number}
* @public
*/
this.siteId = siteId;
}
/**
* Create a new **FreshPackBinLotModel** 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 FreshPack Bin Lot
* @return {FreshPackBinLotModel}
*/
static fromJSON(json, siteId)
{
let model = new FreshPackBinLotModel(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('binTipId' in jsonObject)
{
model.binTipId = (function(){
if(typeof jsonObject['binTipId'] !== 'string')
{
return String(jsonObject['binTipId']);
}
return jsonObject['binTipId'];
}());
}
if('binLotCode' in jsonObject)
{
model.binLotCode = (function(){
if(typeof jsonObject['binLotCode'] !== 'string')
{
return String(jsonObject['binLotCode']);
}
return jsonObject['binLotCode'];
}());
}
if('createdTimestamp' in jsonObject)
{
model.createdTimestamp = (function(){
if(typeof jsonObject['createdTimestamp'] !== 'string')
{
return new Date(String(jsonObject['createdTimestamp']));
}
return new Date(jsonObject['createdTimestamp']);
}());
}
if('packrunIds' in jsonObject)
{
model.packrunIds = (function(){
if(Array.isArray(jsonObject['packrunIds']) !== true)
{
return [];
}
return jsonObject['packrunIds'].map((packrunIdsItem) => {
return (function(){
if(typeof packrunIdsItem !== 'string')
{
return String(packrunIdsItem);
}
return packrunIdsItem;
}());
});
}());
}
if('binNumbers' in jsonObject)
{
model.binNumbers = (function(){
if(Array.isArray(jsonObject['binNumbers']) !== true)
{
return [];
}
return jsonObject['binNumbers'].map((binNumbersItem) => {
return (function(){
if(typeof binNumbersItem !== 'string')
{
return String(binNumbersItem);
}
return binNumbersItem;
}());
});
}());
}
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 FreshPackBinLotModel;
source