RICADO Gen 4 API JS Client

RICADO Gen 4 API JS Client

source

Models/Packhouse/Site/SoftSortPackrunSummaryModel.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 Soft-Sort Packrun Summary
 * 
 * @class
 * @hideconstructor
 * @extends BaseModel
 */
class SoftSortPackrunSummaryModel extends BaseModel
{
    /**
     * SoftSortPackrunSummaryModel Constructor
     * 
     * @protected
     * @param {number} siteId The Site ID associated with this Soft-Sort Packrun Summary
     */
    constructor(siteId)
    {
        super();
        
        /**
         * The Soft-Sort Packrun Summary ID
         * 
         * @type {string}
         * @public
         */
        this.id = "";
        
        /**
         * The Packing Line ID this Summary is associated with
         * 
         * @type {string}
         * @public
         */
        this.packingLineId = "";
        
        /**
         * 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 Number of Soft-Sort Events per Bin Tipped
         * 
         * @type {number}
         * @public
         */
        this.eventsPerBin = 0;
        
        /**
         * The Number of Soft-Sort Events that occurred for the Packrun
         * 
         * @type {number}
         * @public
         */
        this.totalEventsCount = 0;
        
        /**
         * The Average Duration of Soft-Sort Events for the Packrun expressed in Seconds
         * 
         * @type {number}
         * @public
         */
        this.averageEventsDuration = 0;
        
        /**
         * The Total Duration of all Soft-Sort Events for the Packrun expressed in Seconds
         * 
         * @type {number}
         * @public
         */
        this.totalEventsDuration = 0;
        
        /**
         * Whether the Soft-Sort Events Data for this Summary has been Finalized
         * 
         * @type {?Date}
         * @public
         */
        this.eventsFinalizedTimestamp = null;
        
        /**
         * Whether the Soft-Sort Events for this Summary are considered accurate or not
         * 
         * @type {?boolean}
         * @public
         */
        this.eventsAccurate = null;
        
        /**
         * A Reason for why the Events for this Summary are not accurate. Applies when `eventsAccurate` is false
         * 
         * @type {?string}
         * @public
         */
        this.eventsNotAccurateReason = null;
        
        /**
         * Results from Interacting with the FreshPack API to Send Soft-Sort Events Data
         * 
         * @type {?{requestCount: number, requestTimestamp: ?Date, responseCode: ?number, responseMessage: ?string, completed: boolean}}
         * @public
         */
        this.freshPackSoftSortApi = null;
        
        /**
         * Whether the Soft-Sort Packrun Summary has been deleted
         * 
         * @type {boolean}
         * @public
         */
        this.deleted = false;
        
        /**
         * When the Soft-Sort Packrun Summary was last updated
         * 
         * @type {Date}
         * @public
         */
        this.updateTimestamp = new Date();
        
        /**
         * The Site ID associated with this Soft-Sort Packrun Summary
         * 
         * @type {number}
         * @public
         */
        this.siteId = siteId;
    }

    /**
     * Create a new **SoftSortPackrunSummaryModel** 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 Soft-Sort Packrun Summary
     * @return {SoftSortPackrunSummaryModel}
     */
    static fromJSON(json, siteId)
    {
        let model = new SoftSortPackrunSummaryModel(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('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('eventsPerBin' in jsonObject)
        {
            model.eventsPerBin = (function(){
                if(typeof jsonObject['eventsPerBin'] !== 'number')
                {
                    return Number(jsonObject['eventsPerBin']);
                }
        
                return jsonObject['eventsPerBin'];
            }());
        }
        
        if('totalEventsCount' in jsonObject)
        {
            model.totalEventsCount = (function(){
                if(typeof jsonObject['totalEventsCount'] !== 'number')
                {
                    return Number.isInteger(Number(jsonObject['totalEventsCount'])) ? Number(jsonObject['totalEventsCount']) : Math.floor(Number(jsonObject['totalEventsCount']));
                }
        
                return Number.isInteger(jsonObject['totalEventsCount']) ? jsonObject['totalEventsCount'] : Math.floor(jsonObject['totalEventsCount']);
            }());
        }
        
        if('averageEventsDuration' in jsonObject)
        {
            model.averageEventsDuration = (function(){
                if(typeof jsonObject['averageEventsDuration'] !== 'number')
                {
                    return Number(jsonObject['averageEventsDuration']);
                }
        
                return jsonObject['averageEventsDuration'];
            }());
        }
        
        if('totalEventsDuration' in jsonObject)
        {
            model.totalEventsDuration = (function(){
                if(typeof jsonObject['totalEventsDuration'] !== 'number')
                {
                    return Number(jsonObject['totalEventsDuration']);
                }
        
                return jsonObject['totalEventsDuration'];
            }());
        }
        
        if('eventsFinalizedTimestamp' in jsonObject)
        {
            model.eventsFinalizedTimestamp = (function(){
                if(jsonObject['eventsFinalizedTimestamp'] === null)
                {
                    return null;
                }
        
                if(typeof jsonObject['eventsFinalizedTimestamp'] !== 'string')
                {
                    return new Date(String(jsonObject['eventsFinalizedTimestamp']));
                }
        
                return new Date(jsonObject['eventsFinalizedTimestamp']);
            }());
        }
        
        if('eventsAccurate' in jsonObject)
        {
            model.eventsAccurate = (function(){
                if(jsonObject['eventsAccurate'] === null)
                {
                    return null;
                }
        
                if(typeof jsonObject['eventsAccurate'] !== 'boolean')
                {
                    return Boolean(jsonObject['eventsAccurate']);
                }
        
                return jsonObject['eventsAccurate'];
            }());
        }
        
        if('eventsNotAccurateReason' in jsonObject)
        {
            model.eventsNotAccurateReason = (function(){
                if(jsonObject['eventsNotAccurateReason'] === null)
                {
                    return null;
                }
        
                if(typeof jsonObject['eventsNotAccurateReason'] !== 'string')
                {
                    return String(jsonObject['eventsNotAccurateReason']);
                }
        
                return jsonObject['eventsNotAccurateReason'];
            }());
        }
        
        if('freshPackSoftSortApi' in jsonObject)
        {
            model.freshPackSoftSortApi = (function(){
                if(jsonObject['freshPackSoftSortApi'] === null)
                {
                    return null;
                }
        
                let freshPackSoftSortApiObject = {};
                
                if(typeof jsonObject['freshPackSoftSortApi'] === 'object' && 'requestCount' in jsonObject['freshPackSoftSortApi'])
                {
                    freshPackSoftSortApiObject.requestCount = (function(){
                        if(typeof jsonObject['freshPackSoftSortApi'].requestCount !== 'number')
                        {
                            return Number.isInteger(Number(jsonObject['freshPackSoftSortApi'].requestCount)) ? Number(jsonObject['freshPackSoftSortApi'].requestCount) : Math.floor(Number(jsonObject['freshPackSoftSortApi'].requestCount));
                        }
        
                        return Number.isInteger(jsonObject['freshPackSoftSortApi'].requestCount) ? jsonObject['freshPackSoftSortApi'].requestCount : Math.floor(jsonObject['freshPackSoftSortApi'].requestCount);
                    }());
                }
                else
                {
                    freshPackSoftSortApiObject.requestCount = 0;
                }
                
                if(typeof jsonObject['freshPackSoftSortApi'] === 'object' && 'requestTimestamp' in jsonObject['freshPackSoftSortApi'])
                {
                    freshPackSoftSortApiObject.requestTimestamp = (function(){
                        if(jsonObject['freshPackSoftSortApi'].requestTimestamp === null)
                        {
                            return null;
                        }
        
                        if(typeof jsonObject['freshPackSoftSortApi'].requestTimestamp !== 'string')
                        {
                            return new Date(String(jsonObject['freshPackSoftSortApi'].requestTimestamp));
                        }
        
                        return new Date(jsonObject['freshPackSoftSortApi'].requestTimestamp);
                    }());
                }
                else
                {
                    freshPackSoftSortApiObject.requestTimestamp = null;
                }
                
                if(typeof jsonObject['freshPackSoftSortApi'] === 'object' && 'responseCode' in jsonObject['freshPackSoftSortApi'])
                {
                    freshPackSoftSortApiObject.responseCode = (function(){
                        if(jsonObject['freshPackSoftSortApi'].responseCode === null)
                        {
                            return null;
                        }
        
                        if(typeof jsonObject['freshPackSoftSortApi'].responseCode !== 'number')
                        {
                            return Number.isInteger(Number(jsonObject['freshPackSoftSortApi'].responseCode)) ? Number(jsonObject['freshPackSoftSortApi'].responseCode) : Math.floor(Number(jsonObject['freshPackSoftSortApi'].responseCode));
                        }
        
                        return Number.isInteger(jsonObject['freshPackSoftSortApi'].responseCode) ? jsonObject['freshPackSoftSortApi'].responseCode : Math.floor(jsonObject['freshPackSoftSortApi'].responseCode);
                    }());
                }
                else
                {
                    freshPackSoftSortApiObject.responseCode = null;
                }
                
                if(typeof jsonObject['freshPackSoftSortApi'] === 'object' && 'responseMessage' in jsonObject['freshPackSoftSortApi'])
                {
                    freshPackSoftSortApiObject.responseMessage = (function(){
                        if(jsonObject['freshPackSoftSortApi'].responseMessage === null)
                        {
                            return null;
                        }
        
                        if(typeof jsonObject['freshPackSoftSortApi'].responseMessage !== 'string')
                        {
                            return String(jsonObject['freshPackSoftSortApi'].responseMessage);
                        }
        
                        return jsonObject['freshPackSoftSortApi'].responseMessage;
                    }());
                }
                else
                {
                    freshPackSoftSortApiObject.responseMessage = null;
                }
                
                if(typeof jsonObject['freshPackSoftSortApi'] === 'object' && 'completed' in jsonObject['freshPackSoftSortApi'])
                {
                    freshPackSoftSortApiObject.completed = (function(){
                        if(typeof jsonObject['freshPackSoftSortApi'].completed !== 'boolean')
                        {
                            return Boolean(jsonObject['freshPackSoftSortApi'].completed);
                        }
        
                        return jsonObject['freshPackSoftSortApi'].completed;
                    }());
                }
                else
                {
                    freshPackSoftSortApiObject.completed = false;
                }
        
                return freshPackSoftSortApiObject;
            }());
        }
        
        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 SoftSortPackrunSummaryModel;