/**
 * CoinAPI Indexes REST API
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: v1
 * Contact: support@apibricks.io
 *
 * 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';
import IndexesIndexValueComponent from './IndexesIndexValueComponent';

/**
 * The IndexesIndexValue model module.
 * @module model/IndexesIndexValue
 * @version v1
 */
class IndexesIndexValue {
    /**
     * Constructs a new <code>IndexesIndexValue</code>.
     * @alias module:model/IndexesIndexValue
     */
    constructor() { 
        
        IndexesIndexValue.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>IndexesIndexValue</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 {module:model/IndexesIndexValue} obj Optional instance to populate.
     * @return {module:model/IndexesIndexValue} The populated <code>IndexesIndexValue</code> instance.
     */
    static constructFromObject(data, obj) {
        if (data) {
            obj = obj || new IndexesIndexValue();

            if (data.hasOwnProperty('timestamp')) {
                obj['timestamp'] = ApiClient.convertToType(data['timestamp'], 'Date');
            }
            if (data.hasOwnProperty('value')) {
                obj['value'] = ApiClient.convertToType(data['value'], 'Number');
            }
            if (data.hasOwnProperty('composition')) {
                obj['composition'] = ApiClient.convertToType(data['composition'], [IndexesIndexValueComponent]);
            }
        }
        return obj;
    }

    /**
     * Validates the JSON data with respect to <code>IndexesIndexValue</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>IndexesIndexValue</code>.
     */
    static validateJSON(data) {
        if (data['composition']) { // data not null
            // ensure the json data is an array
            if (!Array.isArray(data['composition'])) {
                throw new Error("Expected the field `composition` to be an array in the JSON data but got " + data['composition']);
            }
            // validate the optional field `composition` (array)
            for (const item of data['composition']) {
                IndexesIndexValueComponent.validateJSON(item);
            };
        }

        return true;
    }


}



/**
 * @member {Date} timestamp
 */
IndexesIndexValue.prototype['timestamp'] = undefined;

/**
 * @member {Number} value
 */
IndexesIndexValue.prototype['value'] = undefined;

/**
 * @member {Array.<module:model/IndexesIndexValueComponent>} composition
 */
IndexesIndexValue.prototype['composition'] = undefined;






export default IndexesIndexValue;

