/**
* OpenAPI definition
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: v0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*
*/
import {ApiClient} from '../ApiClient.js';
import { VRObject } from './VRObject.js';
/**
* The PersistentEvent model module.
* @module model/PersistentEvent
* @version v0
*/
export class PersistentEvent {
/**
* Constructs a new <code>PersistentEvent</code>.
* Persistent version of event that can be stored to the database.
* @alias PersistentEvent
*/
constructor() {
/** id
* @type {String}
*/
this.id = undefined;
/** delay
* @type {Number}
*/
this.delay = undefined;
/** type
* @type {String}
*/
this.type = undefined;
/** add
* @type {Array.<VRObject>}
*/
this.add = undefined;
/** remove
* @type {Array.<Object.<String, String>>}
*/
this.remove = undefined;
/** changes
* @type {Object.<String, Object>}
*/
this.changes = undefined;
PersistentEvent.initialize(this);
}
/**
* Initializes the fields of this object.
* This method is used by the constructors of any subclasses, in order to implement multiple inheritance (mix-ins).
* Only for internal use.
*/
static initialize(obj) {
}
/**
* Constructs a <code>PersistentEvent</code> from a plain JavaScript object, optionally creating a new instance.
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @param {PersistentEvent} obj Optional instance to populate.
* @return {PersistentEvent} The populated <code>PersistentEvent</code> instance.
*/
static constructFromObject(data, obj) {
if (data) {
obj = obj || new PersistentEvent();
if (data.hasOwnProperty('id')) {
obj['id'] = ApiClient.convertToType(data['id'], 'String');
}
if (data.hasOwnProperty('delay')) {
obj['delay'] = ApiClient.convertToType(data['delay'], 'Number');
}
if (data.hasOwnProperty('type')) {
obj['type'] = ApiClient.convertToType(data['type'], 'String');
}
if (data.hasOwnProperty('add')) {
obj['add'] = ApiClient.convertToType(data['add'], [VRObject]);
}
if (data.hasOwnProperty('remove')) {
obj['remove'] = ApiClient.convertToType(data['remove'], [{'String': 'String'}]);
}
if (data.hasOwnProperty('changes')) {
obj['changes'] = ApiClient.convertToType(data['changes'], {'String': Object});
}
}
return obj;
}
/**
* Validates the JSON data with respect to <code>PersistentEvent</code>.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>PersistentEvent</code>.
*/
static validateJSON(data) {
// ensure the json data is a string
if (data['id'] && !(typeof data['id'] === 'string' || data['id'] instanceof String)) {
throw new Error("Expected the field `id` to be a primitive type in the JSON string but got " + data['id']);
}
// ensure the json data is a string
if (data['type'] && !(typeof data['type'] === 'string' || data['type'] instanceof String)) {
throw new Error("Expected the field `type` to be a primitive type in the JSON string but got " + data['type']);
}
if (data['add']) { // data not null
// ensure the json data is an array
if (!Array.isArray(data['add'])) {
throw new Error("Expected the field `add` to be an array in the JSON data but got " + data['add']);
}
// validate the optional field `add` (array)
for (const item of data['add']) {
VRObject.validateJSON(item);
};
}
// ensure the json data is an array
if (!Array.isArray(data['remove'])) {
throw new Error("Expected the field `remove` to be an array in the JSON data but got " + data['remove']);
}
return true;
}
}
export default PersistentEvent;