/**
* 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 RTU
*
* @class
* @hideconstructor
* @extends BaseModel
*/
class RTUModel extends BaseModel
{
/**
* RTUModel Constructor
*
* @protected
*/
constructor()
{
super();
/**
* The RTU ID
*
* @type {number}
* @public
*/
this.id = 0;
/**
* The Site this RTU belongs to
*
* @type {number}
* @public
*/
this.siteId = 0;
/**
* The RTU Name
*
* @type {string}
* @public
*/
this.name = "";
/**
* Whether the RTU is Enabled
*
* @type {boolean}
* @public
*/
this.enabled = false;
/**
* Whether the RTU has been deleted
*
* @type {boolean}
* @public
*/
this.deleted = false;
/**
* When the RTU was last updated
*
* @type {Date}
* @public
*/
this.updateTimestamp = new Date();
}
/**
* Create a new **RTUModel** from a JSON Object or JSON String
*
* @static
* @public
* @param {Object<string, any>|string} json A JSON Object or JSON String
* @return {RTUModel}
*/
static fromJSON(json)
{
let model = new RTUModel();
/**
* 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'] !== 'number')
{
return Number.isInteger(Number(jsonObject['id'])) ? Number(jsonObject['id']) : Math.floor(Number(jsonObject['id']));
}
return Number.isInteger(jsonObject['id']) ? jsonObject['id'] : Math.floor(jsonObject['id']);
}());
}
if('siteId' in jsonObject)
{
model.siteId = (function(){
if(typeof jsonObject['siteId'] !== 'number')
{
return Number.isInteger(Number(jsonObject['siteId'])) ? Number(jsonObject['siteId']) : Math.floor(Number(jsonObject['siteId']));
}
return Number.isInteger(jsonObject['siteId']) ? jsonObject['siteId'] : Math.floor(jsonObject['siteId']);
}());
}
if('name' in jsonObject)
{
model.name = (function(){
if(typeof jsonObject['name'] !== 'string')
{
return String(jsonObject['name']);
}
return jsonObject['name'];
}());
}
if('enabled' in jsonObject)
{
model.enabled = (function(){
if(typeof jsonObject['enabled'] !== 'boolean')
{
return Boolean(jsonObject['enabled']);
}
return jsonObject['enabled'];
}());
}
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 RTUModel;
source