RICADO Gen 4 API JS Client

RICADO Gen 4 API JS Client

source

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

    /**
     * Create a new **CompacSizerOutletProductChangeModel** 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 Product Change
     * @return {CompacSizerOutletProductChangeModel}
     */
    static fromJSON(json, siteId)
    {
        let model = new CompacSizerOutletProductChangeModel(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('previousProductId' in jsonObject)
        {
            model.previousProductId = (function(){
                if(jsonObject['previousProductId'] === null)
                {
                    return null;
                }
        
                if(typeof jsonObject['previousProductId'] !== 'string')
                {
                    return String(jsonObject['previousProductId']);
                }
        
                return jsonObject['previousProductId'];
            }());
        }
        
        if('previousProductName' in jsonObject)
        {
            model.previousProductName = (function(){
                if(jsonObject['previousProductName'] === null)
                {
                    return null;
                }
        
                if(typeof jsonObject['previousProductName'] !== 'string')
                {
                    return String(jsonObject['previousProductName']);
                }
        
                return jsonObject['previousProductName'];
            }());
        }
        
        if('newProductId' in jsonObject)
        {
            model.newProductId = (function(){
                if(typeof jsonObject['newProductId'] !== 'string')
                {
                    return String(jsonObject['newProductId']);
                }
        
                return jsonObject['newProductId'];
            }());
        }
        
        if('newProductName' in jsonObject)
        {
            model.newProductName = (function(){
                if(typeof jsonObject['newProductName'] !== 'string')
                {
                    return String(jsonObject['newProductName']);
                }
        
                return jsonObject['newProductName'];
            }());
        }
        
        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 CompacSizerOutletProductChangeModel;