/**
* GameBrain API
* GameBrain API
*
* The version of the OpenAPI document: 1.0.1
* Contact: mail@gamebrain.co
*
* 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 GameNewsItem from './GameNewsItem';
/**
* The GameNewsResponse model module.
* @module model/GameNewsResponse
* @version 1.0.2
*/
class GameNewsResponse {
/**
* Constructs a new <code>GameNewsResponse</code>.
* @alias module:model/GameNewsResponse
* @param news {Array.<module:model/GameNewsItem>}
*/
constructor(news) {
GameNewsResponse.initialize(this, news);
}
/**
* 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, news) {
obj['news'] = news;
}
/**
* Constructs a <code>GameNewsResponse</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/GameNewsResponse} obj Optional instance to populate.
* @return {module:model/GameNewsResponse} The populated <code>GameNewsResponse</code> instance.
*/
static constructFromObject(data, obj) {
if (data) {
obj = obj || new GameNewsResponse();
if (data.hasOwnProperty('news')) {
obj['news'] = ApiClient.convertToType(data['news'], [GameNewsItem]);
}
}
return obj;
}
/**
* Validates the JSON data with respect to <code>GameNewsResponse</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>GameNewsResponse</code>.
*/
static validateJSON(data) {
// check to make sure all required properties are present in the JSON string
for (const property of GameNewsResponse.RequiredProperties) {
if (!data.hasOwnProperty(property)) {
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
}
}
if (data['news']) { // data not null
// ensure the json data is an array
if (!Array.isArray(data['news'])) {
throw new Error("Expected the field `news` to be an array in the JSON data but got " + data['news']);
}
// validate the optional field `news` (array)
for (const item of data['news']) {
GameNewsItem.validateJSON(item);
};
}
return true;
}
}
GameNewsResponse.RequiredProperties = ["news"];
/**
* @member {Array.<module:model/GameNewsItem>} news
*/
GameNewsResponse.prototype['news'] = undefined;
export default GameNewsResponse;