RICADO Gen 4 API JS Client

RICADO Gen 4 API JS Client

source

Models/UserAccountActionTokenModel.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 User Account Action Token
 * 
 * @class
 * @hideconstructor
 * @extends BaseModel
 */
class UserAccountActionTokenModel extends BaseModel
{
    /**
     * UserAccountActionTokenModel Constructor
     * 
     * @protected
     */
    constructor()
    {
        super();
        
        /**
         * The User Account Action Token ID
         * 
         * @type {string}
         * @public
         */
        this.id = "";
        
        /**
         * The Account this Action Token belongs to
         * 
         * @type {string}
         * @public
         */
        this.accountId = "";
        
        /**
         * The Company this Action Token belongs to
         * 
         * @type {string}
         * @public
         */
        this.companyId = "";
        
        /**
         * The Action that can be Performed using this Action Token
         * 
         * @type {string}
         * @public
         */
        this.action = "";
        
        /**
         * When the Action Token was issued
         * 
         * @type {Date}
         * @public
         */
        this.issueTimestamp = new Date();
        
        /**
         * When the Action Token will expire
         * 
         * @type {Date}
         * @public
         */
        this.expireTimestamp = new Date();
        
        /**
         * When the last API call using this Action Token was made
         * 
         * @type {?Date}
         * @public
         */
        this.activityTimestamp = null;
        
        /**
         * When the Action was Completed
         * 
         * @type {?Date}
         * @public
         */
        this.completedTimestamp = null;
        
        /**
         * When the Action Email was Sent
         * 
         * @type {?Date}
         * @public
         */
        this.emailTimestamp = null;
        
        /**
         * Whether the User Account Action Token has been deleted
         * 
         * @type {boolean}
         * @public
         */
        this.deleted = false;
        
        /**
         * When the User Account Action Token was last updated
         * 
         * @type {Date}
         * @public
         */
        this.updateTimestamp = new Date();
    }

    /**
     * Create a new **UserAccountActionTokenModel** from a JSON Object or JSON String
     * 
     * @static
     * @public
     * @param {Object<string, any>|string} json A JSON Object or JSON String
     * @return {UserAccountActionTokenModel}
     */
    static fromJSON(json)
    {
        let model = new UserAccountActionTokenModel();
        
        /**
         * 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('companyId' in jsonObject)
        {
            model.companyId = (function(){
                if(typeof jsonObject['companyId'] !== 'string')
                {
                    return String(jsonObject['companyId']);
                }
        
                return jsonObject['companyId'];
            }());
        }
        
        if('action' in jsonObject)
        {
            model.action = (function(){
                if(typeof jsonObject['action'] !== 'string')
                {
                    return String(jsonObject['action']);
                }
        
                return jsonObject['action'];
            }());
        }
        
        if('issueTimestamp' in jsonObject)
        {
            model.issueTimestamp = (function(){
                if(typeof jsonObject['issueTimestamp'] !== 'string')
                {
                    return new Date(String(jsonObject['issueTimestamp']));
                }
        
                return new Date(jsonObject['issueTimestamp']);
            }());
        }
        
        if('expireTimestamp' in jsonObject)
        {
            model.expireTimestamp = (function(){
                if(typeof jsonObject['expireTimestamp'] !== 'string')
                {
                    return new Date(String(jsonObject['expireTimestamp']));
                }
        
                return new Date(jsonObject['expireTimestamp']);
            }());
        }
        
        if('activityTimestamp' in jsonObject)
        {
            model.activityTimestamp = (function(){
                if(jsonObject['activityTimestamp'] === null)
                {
                    return null;
                }
        
                if(typeof jsonObject['activityTimestamp'] !== 'string')
                {
                    return new Date(String(jsonObject['activityTimestamp']));
                }
        
                return new Date(jsonObject['activityTimestamp']);
            }());
        }
        
        if('completedTimestamp' in jsonObject)
        {
            model.completedTimestamp = (function(){
                if(jsonObject['completedTimestamp'] === null)
                {
                    return null;
                }
        
                if(typeof jsonObject['completedTimestamp'] !== 'string')
                {
                    return new Date(String(jsonObject['completedTimestamp']));
                }
        
                return new Date(jsonObject['completedTimestamp']);
            }());
        }
        
        if('emailTimestamp' in jsonObject)
        {
            model.emailTimestamp = (function(){
                if(jsonObject['emailTimestamp'] === null)
                {
                    return null;
                }
        
                if(typeof jsonObject['emailTimestamp'] !== 'string')
                {
                    return new Date(String(jsonObject['emailTimestamp']));
                }
        
                return new Date(jsonObject['emailTimestamp']);
            }());
        }
        
        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 UserAccountActionTokenModel;