RICADO Gen 4 API JS Client

RICADO Gen 4 API JS Client

source

Models/Packhouse/Site/ShiftGrowerChangeMeetingModel.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 Shift Grower Change Meeting
 * 
 * @class
 * @hideconstructor
 * @extends BaseModel
 */
class ShiftGrowerChangeMeetingModel extends BaseModel
{
    /**
     * ShiftGrowerChangeMeetingModel Constructor
     * 
     * @protected
     * @param {number} siteId The Site ID associated with this Shift Grower Change Meeting
     */
    constructor(siteId)
    {
        super();
        
        /**
         * The Shift Grower Change Meeting ID
         * 
         * @type {string}
         * @public
         */
        this.id = "";
        
        /**
         * The Packing Line ID this Grower Change Meeting is associated with
         * 
         * @type {string}
         * @public
         */
        this.packingLineId = "";
        
        /**
         * The Shift ID this Grower Change Meeting is asssociated with
         * 
         * @type {string}
         * @public
         */
        this.shiftId = "";
        
        /**
         * When this Grower Change Meeting was Created
         * 
         * @type {Date}
         * @public
         */
        this.createdTimestamp = new Date();
        
        /**
         * When this Grower Change Meeting is Scheduled to Begin
         * 
         * @type {Date}
         * @public
         */
        this.scheduledTimestamp = new Date();
        
        /**
         * When this Grower Change Meeting was Started
         * 
         * @type {?Date}
         * @public
         */
        this.startTimestamp = null;
        
        /**
         * When this Grower Change Meeting was Completed
         * 
         * @type {?Date}
         * @public
         */
        this.finishTimestamp = null;
        
        /**
         * The Packrun ID this Grower Change Meeting relates to
         * 
         * @type {string}
         * @public
         */
        this.packrunId = "";
        
        /**
         * An Optional Rating between 1 and 10 on how Useful the Grower Change Meeting was
         * 
         * @type {?number}
         * @public
         */
        this.usefulRating = null;
        
        /**
         * The Status of this Grower Change Meeting
         * 
         * @type {string}
         * @public
         */
        this.status = "";
        
        /**
         * Whether the Shift Grower Change Meeting has been deleted
         * 
         * @type {boolean}
         * @public
         */
        this.deleted = false;
        
        /**
         * When the Shift Grower Change Meeting was last updated
         * 
         * @type {Date}
         * @public
         */
        this.updateTimestamp = new Date();
        
        /**
         * The Site ID associated with this Shift Grower Change Meeting
         * 
         * @type {number}
         * @public
         */
        this.siteId = siteId;
    }

    /**
     * Create a new **ShiftGrowerChangeMeetingModel** 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 Grower Change Meeting
     * @return {ShiftGrowerChangeMeetingModel}
     */
    static fromJSON(json, siteId)
    {
        let model = new ShiftGrowerChangeMeetingModel(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('scheduledTimestamp' in jsonObject)
        {
            model.scheduledTimestamp = (function(){
                if(typeof jsonObject['scheduledTimestamp'] !== 'string')
                {
                    return new Date(String(jsonObject['scheduledTimestamp']));
                }
        
                return new Date(jsonObject['scheduledTimestamp']);
            }());
        }
        
        if('startTimestamp' in jsonObject)
        {
            model.startTimestamp = (function(){
                if(jsonObject['startTimestamp'] === null)
                {
                    return null;
                }
        
                if(typeof jsonObject['startTimestamp'] !== 'string')
                {
                    return new Date(String(jsonObject['startTimestamp']));
                }
        
                return new Date(jsonObject['startTimestamp']);
            }());
        }
        
        if('finishTimestamp' in jsonObject)
        {
            model.finishTimestamp = (function(){
                if(jsonObject['finishTimestamp'] === null)
                {
                    return null;
                }
        
                if(typeof jsonObject['finishTimestamp'] !== 'string')
                {
                    return new Date(String(jsonObject['finishTimestamp']));
                }
        
                return new Date(jsonObject['finishTimestamp']);
            }());
        }
        
        if('packrunId' in jsonObject)
        {
            model.packrunId = (function(){
                if(typeof jsonObject['packrunId'] !== 'string')
                {
                    return String(jsonObject['packrunId']);
                }
        
                return jsonObject['packrunId'];
            }());
        }
        
        if('usefulRating' in jsonObject)
        {
            model.usefulRating = (function(){
                if(jsonObject['usefulRating'] === null)
                {
                    return null;
                }
        
                if(typeof jsonObject['usefulRating'] !== 'number')
                {
                    return Number.isInteger(Number(jsonObject['usefulRating'])) ? Number(jsonObject['usefulRating']) : Math.floor(Number(jsonObject['usefulRating']));
                }
        
                return Number.isInteger(jsonObject['usefulRating']) ? jsonObject['usefulRating'] : Math.floor(jsonObject['usefulRating']);
            }());
        }
        
        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 ShiftGrowerChangeMeetingModel;