Source: client/openapi/model/Client.js

/**
 * 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 { Animation } from './Animation.js';
import { Point } from './Point.js';
import { Rotation } from './Rotation.js';
import { SceneProperties } from './SceneProperties.js';
import { VRObject } from './VRObject.js';

/**
 * The Client model module.
 * @module model/Client
 * @version v0
 */
export class Client {
    /**
     * Constructs a new <code>Client</code>.
     * Basic client class, adds user-related properties and business logic to  VRObject.
     * @alias Client
     */
    constructor() { 
        
        
        /** id 
         * @type {Number} 
         */
        this.id = undefined;

        /** children 
         * @type {Array.<VRObject>} 
         */
        this.children = undefined;

        /** position 
         * @type {Point} 
         */
        this.position = undefined;

        /** rotation 
         * @type {Rotation} 
         */
        this.rotation = undefined;

        /** scale 
         * @type {Point} 
         */
        this.scale = undefined;

        /** permanent 
         * Permanent objects are always present (e.g. sky)
         * @type {Boolean} 
         */
        this.permanent = undefined;

        /** active 
         * Whether an object is active (can send events). E.g. online users, robots.
         * @type {Boolean} 
         */
        this.active = undefined;

        /** mesh 
         * URL of the file containing the mesh.
         * @type {String} 
         */
        this.mesh = undefined;

        /** script 
         * Script that client runs. To prevent cross-site scripting, this is a read-only  property.
         * @type {String} 
         */
        this.script = undefined;

        /** animation 
         * @type {Animation} 
         */
        this.animation = undefined;

        /** name 
         * Client name - unique ID.
         * @type {String} 
         */
        this.name = undefined;

        /** sceneProperties 
         * @type {SceneProperties} 
         */
        this.sceneProperties = undefined;

        /** userHeight 
         * User's height in real life, used in VR. Transient biometric data.
         * @type {Number} 
         */
        this.userHeight = undefined;

        /** tokens 
         * Tokens used to access video/audio streaming servers, identify conversations  with chatbots etc. Transient, never stored to the database.
         * @type {Object.<String, String>} 
         */
        this.tokens = undefined;

        /** temporary 
         * Temporary objects will be deleted from the database along with their owner
         * @type {Boolean} 
         */
        this.temporary = undefined;

        /** properties 
         * Custom transient object properties
         * @type {Object.<String, Object>} 
         */
        this.properties = undefined;
        
        
        
        
        Client.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>Client</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 {Client} obj Optional instance to populate.
     * @return {Client} The populated <code>Client</code> instance.
     */
    static constructFromObject(data, obj) {
        if (data) {
            obj = obj || new Client();

            if (data.hasOwnProperty('id')) {
                obj['id'] = ApiClient.convertToType(data['id'], 'Number');
            }
            if (data.hasOwnProperty('children')) {
                obj['children'] = ApiClient.convertToType(data['children'], [VRObject]);
            }
            if (data.hasOwnProperty('position')) {
                obj['position'] = Point.constructFromObject(data['position']);
            }
            if (data.hasOwnProperty('rotation')) {
                obj['rotation'] = Rotation.constructFromObject(data['rotation']);
            }
            if (data.hasOwnProperty('scale')) {
                obj['scale'] = Point.constructFromObject(data['scale']);
            }
            if (data.hasOwnProperty('permanent')) {
                obj['permanent'] = ApiClient.convertToType(data['permanent'], 'Boolean');
            }
            if (data.hasOwnProperty('active')) {
                obj['active'] = ApiClient.convertToType(data['active'], 'Boolean');
            }
            if (data.hasOwnProperty('mesh')) {
                obj['mesh'] = ApiClient.convertToType(data['mesh'], 'String');
            }
            if (data.hasOwnProperty('script')) {
                obj['script'] = ApiClient.convertToType(data['script'], 'String');
            }
            if (data.hasOwnProperty('animation')) {
                obj['animation'] = Animation.constructFromObject(data['animation']);
            }
            if (data.hasOwnProperty('name')) {
                obj['name'] = ApiClient.convertToType(data['name'], 'String');
            }
            if (data.hasOwnProperty('sceneProperties')) {
                obj['sceneProperties'] = SceneProperties.constructFromObject(data['sceneProperties']);
            }
            if (data.hasOwnProperty('userHeight')) {
                obj['userHeight'] = ApiClient.convertToType(data['userHeight'], 'Number');
            }
            if (data.hasOwnProperty('tokens')) {
                obj['tokens'] = ApiClient.convertToType(data['tokens'], {'String': 'String'});
            }
            if (data.hasOwnProperty('temporary')) {
                obj['temporary'] = ApiClient.convertToType(data['temporary'], 'Boolean');
            }
            if (data.hasOwnProperty('properties')) {
                obj['properties'] = ApiClient.convertToType(data['properties'], {'String': Object});
            }
        }
        return obj;
    }

    /**
     * Validates the JSON data with respect to <code>Client</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>Client</code>.
     */
    static validateJSON(data) {
        if (data['children']) { // data not null
            // ensure the json data is an array
            if (!Array.isArray(data['children'])) {
                throw new Error("Expected the field `children` to be an array in the JSON data but got " + data['children']);
            }
            // validate the optional field `children` (array)
            for (const item of data['children']) {
                VRObject.validateJSON(item);
            };
        }
        // validate the optional field `position`
        if (data['position']) { // data not null
          Point.validateJSON(data['position']);
        }
        // validate the optional field `rotation`
        if (data['rotation']) { // data not null
          Rotation.validateJSON(data['rotation']);
        }
        // validate the optional field `scale`
        if (data['scale']) { // data not null
          Point.validateJSON(data['scale']);
        }
        // ensure the json data is a string
        if (data['mesh'] && !(typeof data['mesh'] === 'string' || data['mesh'] instanceof String)) {
            throw new Error("Expected the field `mesh` to be a primitive type in the JSON string but got " + data['mesh']);
        }
        // ensure the json data is a string
        if (data['script'] && !(typeof data['script'] === 'string' || data['script'] instanceof String)) {
            throw new Error("Expected the field `script` to be a primitive type in the JSON string but got " + data['script']);
        }
        // validate the optional field `animation`
        if (data['animation']) { // data not null
          Animation.validateJSON(data['animation']);
        }
        // ensure the json data is a string
        if (data['name'] && !(typeof data['name'] === 'string' || data['name'] instanceof String)) {
            throw new Error("Expected the field `name` to be a primitive type in the JSON string but got " + data['name']);
        }
        // validate the optional field `sceneProperties`
        if (data['sceneProperties']) { // data not null
          SceneProperties.validateJSON(data['sceneProperties']);
        }

        return true;
    }


}





export default Client;