/**
* 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 Permanent Object Data
*
* @class
* @hideconstructor
* @extends BaseModel
*/
class PermanentObjectDataModel extends BaseModel
{
/**
* PermanentObjectDataModel Constructor
*
* @protected
* @param {number} siteId The Site ID associated with this Permanent Object Data
*/
constructor(siteId)
{
super();
/**
* The Permanent Object Data ID
*
* @type {string}
* @public
*/
this.id = "";
/**
* An Optional Key Index for this Data
*
* @type {string}
* @public
*/
this.keyIndex = "";
/**
* The Permanent Object this Data is related to
*
* @type {string}
* @public
*/
this.permanentObjectId = "";
/**
* The Permanent Object Data Type
*
* @type {string}
* @public
*/
this.type = "";
/**
* The Timestamp when this Data was Created
*
* @type {Date}
* @public
*/
this.timestamp = new Date();
/**
* The Data Object specific to this Permanent Object Data Type
*
* @type {Object}
* @public
*/
this.data = {}
/**
* Whether the Permanent Object Data has been deleted
*
* @type {boolean}
* @public
*/
this.deleted = false;
/**
* When the Permanent Object Data was last updated
*
* @type {Date}
* @public
*/
this.updateTimestamp = new Date();
/**
* The Site ID associated with this Permanent Object Data
*
* @type {number}
* @public
*/
this.siteId = siteId;
}
/**
* Create a new **PermanentObjectDataModel** 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 Permanent Object Data
* @return {PermanentObjectDataModel}
*/
static fromJSON(json, siteId)
{
let model = new PermanentObjectDataModel(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('keyIndex' in jsonObject)
{
model.keyIndex = (function(){
if(typeof jsonObject['keyIndex'] !== 'string')
{
return String(jsonObject['keyIndex']);
}
return jsonObject['keyIndex'];
}());
}
if('permanentObjectId' in jsonObject)
{
model.permanentObjectId = (function(){
if(typeof jsonObject['permanentObjectId'] !== 'string')
{
return String(jsonObject['permanentObjectId']);
}
return jsonObject['permanentObjectId'];
}());
}
if('type' in jsonObject)
{
model.type = (function(){
if(typeof jsonObject['type'] !== 'string')
{
return String(jsonObject['type']);
}
return jsonObject['type'];
}());
}
if('timestamp' in jsonObject)
{
model.timestamp = (function(){
if(typeof jsonObject['timestamp'] !== 'string')
{
return new Date(String(jsonObject['timestamp']));
}
return new Date(jsonObject['timestamp']);
}());
}
if('data' in jsonObject)
{
model.data = (function(){
if(typeof jsonObject['data'] !== 'object')
{
return Object(jsonObject['data']);
}
return jsonObject['data'];
}());
}
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 PermanentObjectDataModel;
source