RICADO Gen 4 API JS Client

RICADO Gen 4 API JS Client

source

Models/Packhouse/Site/FreshPackFruitTemperatureModel.js

/**
 * 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 Fruit Temperature
 * 
 * @class
 * @hideconstructor
 * @extends BaseModel
 */
class FreshPackFruitTemperatureModel extends BaseModel
{
    /**
     * FreshPackFruitTemperatureModel Constructor
     * 
     * @protected
     * @param {number} siteId The Site ID associated with this FreshPack Fruit Temperature
     */
    constructor(siteId)
    {
        super();
        
        /**
         * The FreshPack Fruit Temperature ID
         * 
         * @type {string}
         * @public
         */
        this.id = "";
        
        /**
         * The Bin Tip ID this Fruit Temperature is associated with
         * 
         * @type {string}
         * @public
         */
        this.binTipId = "";
        
        /**
         * The Fresh Pack Bin Lot ID this Fruit Temperature is associated with
         * 
         * @type {string}
         * @public
         */
        this.freshPackBinLotId = "";
        
        /**
         * When this Fruit Temperature was Created
         * 
         * @type {Date}
         * @public
         */
        this.createdTimestamp = new Date();
        
        /**
         * The Temperature of the Fruit
         * 
         * @type {number}
         * @public
         */
        this.temperature = 0;
        
        /**
         * The Packrun ID associated with this Fruit Temperature
         * 
         * @type {string}
         * @public
         */
        this.packrunId = "";
        
        /**
         * Result from Interacting with the FreshPack API to Send this Fruit Temperature
         * 
         * @type {?{requestCount: number, requestTimestamp: ?Date, responseCode: ?number, responseMessage: ?string, completed: boolean}}
         * @public
         */
        this.freshPackFruitTemperatureApi = null;
        
        /**
         * Whether the FreshPack Fruit Temperature has been deleted
         * 
         * @type {boolean}
         * @public
         */
        this.deleted = false;
        
        /**
         * When the FreshPack Fruit Temperature was last updated
         * 
         * @type {Date}
         * @public
         */
        this.updateTimestamp = new Date();
        
        /**
         * The Site ID associated with this FreshPack Fruit Temperature
         * 
         * @type {number}
         * @public
         */
        this.siteId = siteId;
    }

    /**
     * Create a new **FreshPackFruitTemperatureModel** 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 Fruit Temperature
     * @return {FreshPackFruitTemperatureModel}
     */
    static fromJSON(json, siteId)
    {
        let model = new FreshPackFruitTemperatureModel(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('freshPackBinLotId' in jsonObject)
        {
            model.freshPackBinLotId = (function(){
                if(typeof jsonObject['freshPackBinLotId'] !== 'string')
                {
                    return String(jsonObject['freshPackBinLotId']);
                }
        
                return jsonObject['freshPackBinLotId'];
            }());
        }
        
        if('createdTimestamp' in jsonObject)
        {
            model.createdTimestamp = (function(){
                if(typeof jsonObject['createdTimestamp'] !== 'string')
                {
                    return new Date(String(jsonObject['createdTimestamp']));
                }
        
                return new Date(jsonObject['createdTimestamp']);
            }());
        }
        
        if('temperature' in jsonObject)
        {
            model.temperature = (function(){
                if(typeof jsonObject['temperature'] !== 'number')
                {
                    return Number(jsonObject['temperature']);
                }
        
                return jsonObject['temperature'];
            }());
        }
        
        if('packrunId' in jsonObject)
        {
            model.packrunId = (function(){
                if(typeof jsonObject['packrunId'] !== 'string')
                {
                    return String(jsonObject['packrunId']);
                }
        
                return jsonObject['packrunId'];
            }());
        }
        
        if('freshPackFruitTemperatureApi' in jsonObject)
        {
            model.freshPackFruitTemperatureApi = (function(){
                if(jsonObject['freshPackFruitTemperatureApi'] === null)
                {
                    return null;
                }
        
                let freshPackFruitTemperatureApiObject = {};
                
                if(typeof jsonObject['freshPackFruitTemperatureApi'] === 'object' && 'requestCount' in jsonObject['freshPackFruitTemperatureApi'])
                {
                    freshPackFruitTemperatureApiObject.requestCount = (function(){
                        if(typeof jsonObject['freshPackFruitTemperatureApi'].requestCount !== 'number')
                        {
                            return Number.isInteger(Number(jsonObject['freshPackFruitTemperatureApi'].requestCount)) ? Number(jsonObject['freshPackFruitTemperatureApi'].requestCount) : Math.floor(Number(jsonObject['freshPackFruitTemperatureApi'].requestCount));
                        }
        
                        return Number.isInteger(jsonObject['freshPackFruitTemperatureApi'].requestCount) ? jsonObject['freshPackFruitTemperatureApi'].requestCount : Math.floor(jsonObject['freshPackFruitTemperatureApi'].requestCount);
                    }());
                }
                else
                {
                    freshPackFruitTemperatureApiObject.requestCount = 0;
                }
                
                if(typeof jsonObject['freshPackFruitTemperatureApi'] === 'object' && 'requestTimestamp' in jsonObject['freshPackFruitTemperatureApi'])
                {
                    freshPackFruitTemperatureApiObject.requestTimestamp = (function(){
                        if(jsonObject['freshPackFruitTemperatureApi'].requestTimestamp === null)
                        {
                            return null;
                        }
        
                        if(typeof jsonObject['freshPackFruitTemperatureApi'].requestTimestamp !== 'string')
                        {
                            return new Date(String(jsonObject['freshPackFruitTemperatureApi'].requestTimestamp));
                        }
        
                        return new Date(jsonObject['freshPackFruitTemperatureApi'].requestTimestamp);
                    }());
                }
                else
                {
                    freshPackFruitTemperatureApiObject.requestTimestamp = null;
                }
                
                if(typeof jsonObject['freshPackFruitTemperatureApi'] === 'object' && 'responseCode' in jsonObject['freshPackFruitTemperatureApi'])
                {
                    freshPackFruitTemperatureApiObject.responseCode = (function(){
                        if(jsonObject['freshPackFruitTemperatureApi'].responseCode === null)
                        {
                            return null;
                        }
        
                        if(typeof jsonObject['freshPackFruitTemperatureApi'].responseCode !== 'number')
                        {
                            return Number.isInteger(Number(jsonObject['freshPackFruitTemperatureApi'].responseCode)) ? Number(jsonObject['freshPackFruitTemperatureApi'].responseCode) : Math.floor(Number(jsonObject['freshPackFruitTemperatureApi'].responseCode));
                        }
        
                        return Number.isInteger(jsonObject['freshPackFruitTemperatureApi'].responseCode) ? jsonObject['freshPackFruitTemperatureApi'].responseCode : Math.floor(jsonObject['freshPackFruitTemperatureApi'].responseCode);
                    }());
                }
                else
                {
                    freshPackFruitTemperatureApiObject.responseCode = null;
                }
                
                if(typeof jsonObject['freshPackFruitTemperatureApi'] === 'object' && 'responseMessage' in jsonObject['freshPackFruitTemperatureApi'])
                {
                    freshPackFruitTemperatureApiObject.responseMessage = (function(){
                        if(jsonObject['freshPackFruitTemperatureApi'].responseMessage === null)
                        {
                            return null;
                        }
        
                        if(typeof jsonObject['freshPackFruitTemperatureApi'].responseMessage !== 'string')
                        {
                            return String(jsonObject['freshPackFruitTemperatureApi'].responseMessage);
                        }
        
                        return jsonObject['freshPackFruitTemperatureApi'].responseMessage;
                    }());
                }
                else
                {
                    freshPackFruitTemperatureApiObject.responseMessage = null;
                }
                
                if(typeof jsonObject['freshPackFruitTemperatureApi'] === 'object' && 'completed' in jsonObject['freshPackFruitTemperatureApi'])
                {
                    freshPackFruitTemperatureApiObject.completed = (function(){
                        if(typeof jsonObject['freshPackFruitTemperatureApi'].completed !== 'boolean')
                        {
                            return Boolean(jsonObject['freshPackFruitTemperatureApi'].completed);
                        }
        
                        return jsonObject['freshPackFruitTemperatureApi'].completed;
                    }());
                }
                else
                {
                    freshPackFruitTemperatureApiObject.completed = false;
                }
        
                return freshPackFruitTemperatureApiObject;
            }());
        }
        
        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 FreshPackFruitTemperatureModel;