RICADO Gen 4 API JS Client

RICADO Gen 4 API JS Client

source

Models/FirebaseTokenModel.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 Firebase Token
 * 
 * @class
 * @hideconstructor
 * @extends BaseModel
 */
class FirebaseTokenModel extends BaseModel
{
    /**
     * FirebaseTokenModel Constructor
     * 
     * @protected
     */
    constructor()
    {
        super();
        
        /**
         * The Firebase Token ID
         * 
         * @type {string}
         * @public
         */
        this.id = "";
        
        /**
         * The Account this Firebase Token belongs to
         * 
         * @type {string}
         * @public
         */
        this.accountId = "";
        
        /**
         * The Firebase Token
         * 
         * @type {string}
         * @public
         */
        this.token = "";
        
        /**
         * Whether the Firebase Token should receive Notifications
         * 
         * @type {boolean}
         * @public
         */
        this.enabled = false;
        
        /**
         * The Device Name
         * 
         * @type {string}
         * @public
         */
        this.deviceName = "";
        
        /**
         * The Device Platform
         * 
         * @type {string}
         * @public
         */
        this.devicePlatform = "";
        
        /**
         * Whether the Firebase Token has been deleted
         * 
         * @type {boolean}
         * @public
         */
        this.deleted = false;
        
        /**
         * When the Firebase Token was last updated
         * 
         * @type {Date}
         * @public
         */
        this.updateTimestamp = new Date();
    }

    /**
     * Create a new **FirebaseTokenModel** from a JSON Object or JSON String
     * 
     * @static
     * @public
     * @param {Object<string, any>|string} json A JSON Object or JSON String
     * @return {FirebaseTokenModel}
     */
    static fromJSON(json)
    {
        let model = new FirebaseTokenModel();
        
        /**
         * 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('accountId' in jsonObject)
        {
            model.accountId = (function(){
                if(typeof jsonObject['accountId'] !== 'string')
                {
                    return String(jsonObject['accountId']);
                }
        
                return jsonObject['accountId'];
            }());
        }
        
        if('token' in jsonObject)
        {
            model.token = (function(){
                if(typeof jsonObject['token'] !== 'string')
                {
                    return String(jsonObject['token']);
                }
        
                return jsonObject['token'];
            }());
        }
        
        if('enabled' in jsonObject)
        {
            model.enabled = (function(){
                if(typeof jsonObject['enabled'] !== 'boolean')
                {
                    return Boolean(jsonObject['enabled']);
                }
        
                return jsonObject['enabled'];
            }());
        }
        
        if('deviceName' in jsonObject)
        {
            model.deviceName = (function(){
                if(typeof jsonObject['deviceName'] !== 'string')
                {
                    return String(jsonObject['deviceName']);
                }
        
                return jsonObject['deviceName'];
            }());
        }
        
        if('devicePlatform' in jsonObject)
        {
            model.devicePlatform = (function(){
                if(typeof jsonObject['devicePlatform'] !== 'string')
                {
                    return String(jsonObject['devicePlatform']);
                }
        
                return jsonObject['devicePlatform'];
            }());
        }
        
        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 FirebaseTokenModel;