/**
* 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 Token
*
* @class
* @hideconstructor
* @extends BaseModel
*/
class TokenModel extends BaseModel
{
/**
* TokenModel Constructor
*
* @protected
*/
constructor()
{
super();
/**
* The Token ID
*
* @type {string}
* @public
*/
this.id = "";
/**
* The Account this Token belongs to
*
* @type {string}
* @public
*/
this.accountId = "";
/**
* The Account Type
*
* @type {string}
* @public
*/
this.accountType = "";
/**
* When the Token was issued
*
* @type {Date}
* @public
*/
this.issueTimestamp = new Date();
/**
* When the Token will expire
*
* @type {Date}
* @public
*/
this.expireTimestamp = new Date();
/**
* When the last API call using this Token was made
*
* @type {?Date}
* @public
*/
this.activityTimestamp = null;
/**
* When the Token was unlocked
*
* @type {?Date}
* @public
*/
this.unlockTimestamp = null;
/**
* When the Token was locked
*
* @type {?Date}
* @public
*/
this.lockTimestamp = null;
/**
* Whether the Token has been deleted
*
* @type {boolean}
* @public
*/
this.deleted = false;
/**
* When the Token was last updated
*
* @type {Date}
* @public
*/
this.updateTimestamp = new Date();
}
/**
* Create a new **TokenModel** from a JSON Object or JSON String
*
* @static
* @public
* @param {Object<string, any>|string} json A JSON Object or JSON String
* @return {TokenModel}
*/
static fromJSON(json)
{
let model = new TokenModel();
/**
* 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('accountType' in jsonObject)
{
model.accountType = (function(){
if(typeof jsonObject['accountType'] !== 'string')
{
return String(jsonObject['accountType']);
}
return jsonObject['accountType'];
}());
}
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('unlockTimestamp' in jsonObject)
{
model.unlockTimestamp = (function(){
if(jsonObject['unlockTimestamp'] === null)
{
return null;
}
if(typeof jsonObject['unlockTimestamp'] !== 'string')
{
return new Date(String(jsonObject['unlockTimestamp']));
}
return new Date(jsonObject['unlockTimestamp']);
}());
}
if('lockTimestamp' in jsonObject)
{
model.lockTimestamp = (function(){
if(jsonObject['lockTimestamp'] === null)
{
return null;
}
if(typeof jsonObject['lockTimestamp'] !== 'string')
{
return new Date(String(jsonObject['lockTimestamp']));
}
return new Date(jsonObject['lockTimestamp']);
}());
}
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 TokenModel;
source