/**
* 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;
/**
* Metadata from the Request that generated this Token
*
* @type {{ipAddress: ?string, userAgent: ?string, cloudflareRayId: ?string, host: ?string, referrer: ?string}}
* @public
*/
this.issueMetadata = (function(){
let issueMetadataDefaultValue = {};
issueMetadataDefaultValue.ipAddress = null;
issueMetadataDefaultValue.userAgent = null;
issueMetadataDefaultValue.cloudflareRayId = null;
issueMetadataDefaultValue.host = null;
issueMetadataDefaultValue.referrer = null;
return issueMetadataDefaultValue;
}());
/**
* 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('issueMetadata' in jsonObject)
{
model.issueMetadata = (function(){
let issueMetadataObject = {};
if(typeof jsonObject['issueMetadata'] === 'object' && 'ipAddress' in jsonObject['issueMetadata'])
{
issueMetadataObject.ipAddress = (function(){
if(jsonObject['issueMetadata'].ipAddress === null)
{
return null;
}
if(typeof jsonObject['issueMetadata'].ipAddress !== 'string')
{
return String(jsonObject['issueMetadata'].ipAddress);
}
return jsonObject['issueMetadata'].ipAddress;
}());
}
else
{
issueMetadataObject.ipAddress = null;
}
if(typeof jsonObject['issueMetadata'] === 'object' && 'userAgent' in jsonObject['issueMetadata'])
{
issueMetadataObject.userAgent = (function(){
if(jsonObject['issueMetadata'].userAgent === null)
{
return null;
}
if(typeof jsonObject['issueMetadata'].userAgent !== 'string')
{
return String(jsonObject['issueMetadata'].userAgent);
}
return jsonObject['issueMetadata'].userAgent;
}());
}
else
{
issueMetadataObject.userAgent = null;
}
if(typeof jsonObject['issueMetadata'] === 'object' && 'cloudflareRayId' in jsonObject['issueMetadata'])
{
issueMetadataObject.cloudflareRayId = (function(){
if(jsonObject['issueMetadata'].cloudflareRayId === null)
{
return null;
}
if(typeof jsonObject['issueMetadata'].cloudflareRayId !== 'string')
{
return String(jsonObject['issueMetadata'].cloudflareRayId);
}
return jsonObject['issueMetadata'].cloudflareRayId;
}());
}
else
{
issueMetadataObject.cloudflareRayId = null;
}
if(typeof jsonObject['issueMetadata'] === 'object' && 'host' in jsonObject['issueMetadata'])
{
issueMetadataObject.host = (function(){
if(jsonObject['issueMetadata'].host === null)
{
return null;
}
if(typeof jsonObject['issueMetadata'].host !== 'string')
{
return String(jsonObject['issueMetadata'].host);
}
return jsonObject['issueMetadata'].host;
}());
}
else
{
issueMetadataObject.host = null;
}
if(typeof jsonObject['issueMetadata'] === 'object' && 'referrer' in jsonObject['issueMetadata'])
{
issueMetadataObject.referrer = (function(){
if(jsonObject['issueMetadata'].referrer === null)
{
return null;
}
if(typeof jsonObject['issueMetadata'].referrer !== 'string')
{
return String(jsonObject['issueMetadata'].referrer);
}
return jsonObject['issueMetadata'].referrer;
}());
}
else
{
issueMetadataObject.referrer = null;
}
return issueMetadataObject;
}());
}
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