/**
* 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 Point
*
* @class
* @hideconstructor
* @extends BaseModel
*/
class PointModel extends BaseModel
{
/**
* PointModel Constructor
*
* @protected
* @param {number} siteId The Site ID associated with this Point
*/
constructor(siteId)
{
super();
/**
* The Point ID
*
* @type {number}
* @public
*/
this.id = 0;
/**
* The RTU this Point belongs to
*
* @type {?number}
* @public
*/
this.rtuId = null;
/**
* The Plugin ID
*
* @type {?number}
* @public
*/
this.pluginId = null;
/**
* The Point Name
*
* @type {string}
* @public
*/
this.name = "";
/**
* The Point Type
*
* @type {string}
* @public
*/
this.type = "";
/**
* The Point's Value Type
*
* @type {string}
* @public
*/
this.valueType = "";
/**
* The Permissions
*
* @type {string}
* @public
*/
this.permissions = "";
/**
* Whether the Point is Enabled
*
* @type {boolean}
* @public
*/
this.enabled = false;
/**
* The Point Settings
*
* @type {Object}
* @public
*/
this.settings = {}
/**
* Whether the Point has been deleted
*
* @type {boolean}
* @public
*/
this.deleted = false;
/**
* When the Point was last updated
*
* @type {Date}
* @public
*/
this.updateTimestamp = new Date();
/**
* The Site ID associated with this Point
*
* @type {number}
* @public
*/
this.siteId = siteId;
}
/**
* Create a new **PointModel** 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 Point
* @return {PointModel}
*/
static fromJSON(json, siteId)
{
let model = new PointModel(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'] !== '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('rtuId' in jsonObject)
{
model.rtuId = (function(){
if(jsonObject['rtuId'] === null)
{
return null;
}
if(typeof jsonObject['rtuId'] !== 'number')
{
return Number.isInteger(Number(jsonObject['rtuId'])) ? Number(jsonObject['rtuId']) : Math.floor(Number(jsonObject['rtuId']));
}
return Number.isInteger(jsonObject['rtuId']) ? jsonObject['rtuId'] : Math.floor(jsonObject['rtuId']);
}());
}
if('pluginId' in jsonObject)
{
model.pluginId = (function(){
if(jsonObject['pluginId'] === null)
{
return null;
}
if(typeof jsonObject['pluginId'] !== 'number')
{
return Number.isInteger(Number(jsonObject['pluginId'])) ? Number(jsonObject['pluginId']) : Math.floor(Number(jsonObject['pluginId']));
}
return Number.isInteger(jsonObject['pluginId']) ? jsonObject['pluginId'] : Math.floor(jsonObject['pluginId']);
}());
}
if('name' in jsonObject)
{
model.name = (function(){
if(typeof jsonObject['name'] !== 'string')
{
return String(jsonObject['name']);
}
return jsonObject['name'];
}());
}
if('type' in jsonObject)
{
model.type = (function(){
if(typeof jsonObject['type'] !== 'string')
{
return String(jsonObject['type']);
}
return jsonObject['type'];
}());
}
if('valueType' in jsonObject)
{
model.valueType = (function(){
if(typeof jsonObject['valueType'] !== 'string')
{
return String(jsonObject['valueType']);
}
return jsonObject['valueType'];
}());
}
if('permissions' in jsonObject)
{
model.permissions = (function(){
if(typeof jsonObject['permissions'] !== 'string')
{
return String(jsonObject['permissions']);
}
return jsonObject['permissions'];
}());
}
if('enabled' in jsonObject)
{
model.enabled = (function(){
if(typeof jsonObject['enabled'] !== 'boolean')
{
return Boolean(jsonObject['enabled']);
}
return jsonObject['enabled'];
}());
}
if('settings' in jsonObject)
{
model.settings = (function(){
if(typeof jsonObject['settings'] !== 'object')
{
return Object(jsonObject['settings']);
}
return jsonObject['settings'];
}());
}
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 PointModel;
source