RICADO Gen 4 API JS Client

RICADO Gen 4 API JS Client

source

Models/Packhouse/Site/CompacSizerOutletTypeChangeModel.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 Compac Sizer Outlet Type Change
 * 
 * @class
 * @hideconstructor
 * @extends BaseModel
 */
class CompacSizerOutletTypeChangeModel extends BaseModel
{
    /**
     * CompacSizerOutletTypeChangeModel Constructor
     * 
     * @protected
     * @param {number} siteId The Site ID associated with this Compac Sizer Outlet Type Change
     */
    constructor(siteId)
    {
        super();
        
        /**
         * The Compac Sizer Outlet Type Change ID
         * 
         * @type {string}
         * @public
         */
        this.id = "";
        
        /**
         * The Compac Sizer ID this Outlet Type Change is associated with
         * 
         * @type {string}
         * @public
         */
        this.compacSizerId = "";
        
        /**
         * The Sizer Outlet Number this Outlet Type Change is associated with
         * 
         * @type {string}
         * @public
         */
        this.outletNumber = "";
        
        /**
         * When this Outlet Type Change occurred
         * 
         * @type {Date}
         * @public
         */
        this.createdTimestamp = new Date();
        
        /**
         * The ID of the Previous Type that was active on the Outlet
         * 
         * @type {?string}
         * @public
         */
        this.previousTypeId = null;
        
        /**
         * The ID of the New Type that is now active on the Outlet
         * 
         * @type {string}
         * @public
         */
        this.newTypeId = "";
        
        /**
         * Whether the Compac Sizer Outlet Type Change has been deleted
         * 
         * @type {boolean}
         * @public
         */
        this.deleted = false;
        
        /**
         * When the Compac Sizer Outlet Type Change was last updated
         * 
         * @type {Date}
         * @public
         */
        this.updateTimestamp = new Date();
        
        /**
         * The Site ID associated with this Compac Sizer Outlet Type Change
         * 
         * @type {number}
         * @public
         */
        this.siteId = siteId;
    }

    /**
     * Create a new **CompacSizerOutletTypeChangeModel** 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 Compac Sizer Outlet Type Change
     * @return {CompacSizerOutletTypeChangeModel}
     */
    static fromJSON(json, siteId)
    {
        let model = new CompacSizerOutletTypeChangeModel(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('compacSizerId' in jsonObject)
        {
            model.compacSizerId = (function(){
                if(typeof jsonObject['compacSizerId'] !== 'string')
                {
                    return String(jsonObject['compacSizerId']);
                }
        
                return jsonObject['compacSizerId'];
            }());
        }
        
        if('outletNumber' in jsonObject)
        {
            model.outletNumber = (function(){
                if(typeof jsonObject['outletNumber'] !== 'string')
                {
                    return String(jsonObject['outletNumber']);
                }
        
                return jsonObject['outletNumber'];
            }());
        }
        
        if('createdTimestamp' in jsonObject)
        {
            model.createdTimestamp = (function(){
                if(typeof jsonObject['createdTimestamp'] !== 'string')
                {
                    return new Date(String(jsonObject['createdTimestamp']));
                }
        
                return new Date(jsonObject['createdTimestamp']);
            }());
        }
        
        if('previousTypeId' in jsonObject)
        {
            model.previousTypeId = (function(){
                if(jsonObject['previousTypeId'] === null)
                {
                    return null;
                }
        
                if(typeof jsonObject['previousTypeId'] !== 'string')
                {
                    return String(jsonObject['previousTypeId']);
                }
        
                return jsonObject['previousTypeId'];
            }());
        }
        
        if('newTypeId' in jsonObject)
        {
            model.newTypeId = (function(){
                if(typeof jsonObject['newTypeId'] !== 'string')
                {
                    return String(jsonObject['newTypeId']);
                }
        
                return jsonObject['newTypeId'];
            }());
        }
        
        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 CompacSizerOutletTypeChangeModel;