/**
* 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 GameResponseOffersInner from './GameResponseOffersInner';
import GameResponseOfficialStoresInner from './GameResponseOfficialStoresInner';
import GameResponsePlatformsInner from './GameResponsePlatformsInner';
import GameResponsePlaytime from './GameResponsePlaytime';
import GameResponseRating from './GameResponseRating';
/**
* The GameResponse model module.
* @module model/GameResponse
* @version 1.0.2
*/
class GameResponse {
/**
* Constructs a new <code>GameResponse</code>.
* @alias module:model/GameResponse
*/
constructor() {
GameResponse.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>GameResponse</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/GameResponse} obj Optional instance to populate.
* @return {module:model/GameResponse} The populated <code>GameResponse</code> instance.
*/
static constructFromObject(data, obj) {
if (data) {
obj = obj || new GameResponse();
if (data.hasOwnProperty('id')) {
obj['id'] = ApiClient.convertToType(data['id'], 'Number');
}
if (data.hasOwnProperty('name')) {
obj['name'] = ApiClient.convertToType(data['name'], 'String');
}
if (data.hasOwnProperty('image')) {
obj['image'] = ApiClient.convertToType(data['image'], 'String');
}
if (data.hasOwnProperty('gameplay')) {
obj['gameplay'] = ApiClient.convertToType(data['gameplay'], 'String');
}
if (data.hasOwnProperty('link')) {
obj['link'] = ApiClient.convertToType(data['link'], 'String');
}
if (data.hasOwnProperty('x_url')) {
obj['x_url'] = ApiClient.convertToType(data['x_url'], 'String');
}
if (data.hasOwnProperty('rating')) {
obj['rating'] = GameResponseRating.constructFromObject(data['rating']);
}
if (data.hasOwnProperty('description')) {
obj['description'] = ApiClient.convertToType(data['description'], 'String');
}
if (data.hasOwnProperty('short_description')) {
obj['short_description'] = ApiClient.convertToType(data['short_description'], 'String');
}
if (data.hasOwnProperty('release_date')) {
obj['release_date'] = ApiClient.convertToType(data['release_date'], 'Date');
}
if (data.hasOwnProperty('developer')) {
obj['developer'] = ApiClient.convertToType(data['developer'], 'String');
}
if (data.hasOwnProperty('playtime')) {
obj['playtime'] = GameResponsePlaytime.constructFromObject(data['playtime']);
}
if (data.hasOwnProperty('platforms')) {
obj['platforms'] = ApiClient.convertToType(data['platforms'], [GameResponsePlatformsInner]);
}
if (data.hasOwnProperty('tags')) {
obj['tags'] = ApiClient.convertToType(data['tags'], ['String']);
}
if (data.hasOwnProperty('genres')) {
obj['genres'] = ApiClient.convertToType(data['genres'], [GameResponsePlatformsInner]);
}
if (data.hasOwnProperty('genre')) {
obj['genre'] = ApiClient.convertToType(data['genre'], 'String');
}
if (data.hasOwnProperty('themes')) {
obj['themes'] = ApiClient.convertToType(data['themes'], [GameResponsePlatformsInner]);
}
if (data.hasOwnProperty('adult_only')) {
obj['adult_only'] = ApiClient.convertToType(data['adult_only'], 'Boolean');
}
if (data.hasOwnProperty('play_modes')) {
obj['play_modes'] = ApiClient.convertToType(data['play_modes'], [GameResponsePlatformsInner]);
}
if (data.hasOwnProperty('screenshots')) {
obj['screenshots'] = ApiClient.convertToType(data['screenshots'], ['String']);
}
if (data.hasOwnProperty('videos')) {
obj['videos'] = ApiClient.convertToType(data['videos'], ['String']);
}
if (data.hasOwnProperty('offers')) {
obj['offers'] = ApiClient.convertToType(data['offers'], [GameResponseOffersInner]);
}
if (data.hasOwnProperty('official_stores')) {
obj['official_stores'] = ApiClient.convertToType(data['official_stores'], [GameResponseOfficialStoresInner]);
}
if (data.hasOwnProperty('micro_trailer')) {
obj['micro_trailer'] = ApiClient.convertToType(data['micro_trailer'], 'String');
}
}
return obj;
}
/**
* Validates the JSON data with respect to <code>GameResponse</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>GameResponse</code>.
*/
static validateJSON(data) {
// 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']);
}
// ensure the json data is a string
if (data['image'] && !(typeof data['image'] === 'string' || data['image'] instanceof String)) {
throw new Error("Expected the field `image` to be a primitive type in the JSON string but got " + data['image']);
}
// ensure the json data is a string
if (data['gameplay'] && !(typeof data['gameplay'] === 'string' || data['gameplay'] instanceof String)) {
throw new Error("Expected the field `gameplay` to be a primitive type in the JSON string but got " + data['gameplay']);
}
// ensure the json data is a string
if (data['link'] && !(typeof data['link'] === 'string' || data['link'] instanceof String)) {
throw new Error("Expected the field `link` to be a primitive type in the JSON string but got " + data['link']);
}
// ensure the json data is a string
if (data['x_url'] && !(typeof data['x_url'] === 'string' || data['x_url'] instanceof String)) {
throw new Error("Expected the field `x_url` to be a primitive type in the JSON string but got " + data['x_url']);
}
// validate the optional field `rating`
if (data['rating']) { // data not null
GameResponseRating.validateJSON(data['rating']);
}
// ensure the json data is a string
if (data['description'] && !(typeof data['description'] === 'string' || data['description'] instanceof String)) {
throw new Error("Expected the field `description` to be a primitive type in the JSON string but got " + data['description']);
}
// ensure the json data is a string
if (data['short_description'] && !(typeof data['short_description'] === 'string' || data['short_description'] instanceof String)) {
throw new Error("Expected the field `short_description` to be a primitive type in the JSON string but got " + data['short_description']);
}
// ensure the json data is a string
if (data['developer'] && !(typeof data['developer'] === 'string' || data['developer'] instanceof String)) {
throw new Error("Expected the field `developer` to be a primitive type in the JSON string but got " + data['developer']);
}
// validate the optional field `playtime`
if (data['playtime']) { // data not null
GameResponsePlaytime.validateJSON(data['playtime']);
}
if (data['platforms']) { // data not null
// ensure the json data is an array
if (!Array.isArray(data['platforms'])) {
throw new Error("Expected the field `platforms` to be an array in the JSON data but got " + data['platforms']);
}
// validate the optional field `platforms` (array)
for (const item of data['platforms']) {
GameResponsePlatformsInner.validateJSON(item);
};
}
// ensure the json data is an array
if (!Array.isArray(data['tags'])) {
throw new Error("Expected the field `tags` to be an array in the JSON data but got " + data['tags']);
}
if (data['genres']) { // data not null
// ensure the json data is an array
if (!Array.isArray(data['genres'])) {
throw new Error("Expected the field `genres` to be an array in the JSON data but got " + data['genres']);
}
// validate the optional field `genres` (array)
for (const item of data['genres']) {
GameResponsePlatformsInner.validateJSON(item);
};
}
// ensure the json data is a string
if (data['genre'] && !(typeof data['genre'] === 'string' || data['genre'] instanceof String)) {
throw new Error("Expected the field `genre` to be a primitive type in the JSON string but got " + data['genre']);
}
if (data['themes']) { // data not null
// ensure the json data is an array
if (!Array.isArray(data['themes'])) {
throw new Error("Expected the field `themes` to be an array in the JSON data but got " + data['themes']);
}
// validate the optional field `themes` (array)
for (const item of data['themes']) {
GameResponsePlatformsInner.validateJSON(item);
};
}
if (data['play_modes']) { // data not null
// ensure the json data is an array
if (!Array.isArray(data['play_modes'])) {
throw new Error("Expected the field `play_modes` to be an array in the JSON data but got " + data['play_modes']);
}
// validate the optional field `play_modes` (array)
for (const item of data['play_modes']) {
GameResponsePlatformsInner.validateJSON(item);
};
}
// ensure the json data is an array
if (!Array.isArray(data['screenshots'])) {
throw new Error("Expected the field `screenshots` to be an array in the JSON data but got " + data['screenshots']);
}
// ensure the json data is an array
if (!Array.isArray(data['videos'])) {
throw new Error("Expected the field `videos` to be an array in the JSON data but got " + data['videos']);
}
if (data['offers']) { // data not null
// ensure the json data is an array
if (!Array.isArray(data['offers'])) {
throw new Error("Expected the field `offers` to be an array in the JSON data but got " + data['offers']);
}
// validate the optional field `offers` (array)
for (const item of data['offers']) {
GameResponseOffersInner.validateJSON(item);
};
}
if (data['official_stores']) { // data not null
// ensure the json data is an array
if (!Array.isArray(data['official_stores'])) {
throw new Error("Expected the field `official_stores` to be an array in the JSON data but got " + data['official_stores']);
}
// validate the optional field `official_stores` (array)
for (const item of data['official_stores']) {
GameResponseOfficialStoresInner.validateJSON(item);
};
}
// ensure the json data is a string
if (data['micro_trailer'] && !(typeof data['micro_trailer'] === 'string' || data['micro_trailer'] instanceof String)) {
throw new Error("Expected the field `micro_trailer` to be a primitive type in the JSON string but got " + data['micro_trailer']);
}
return true;
}
}
/**
* @member {Number} id
*/
GameResponse.prototype['id'] = undefined;
/**
* @member {String} name
*/
GameResponse.prototype['name'] = undefined;
/**
* @member {String} image
*/
GameResponse.prototype['image'] = undefined;
/**
* @member {String} gameplay
*/
GameResponse.prototype['gameplay'] = undefined;
/**
* @member {String} link
*/
GameResponse.prototype['link'] = undefined;
/**
* @member {String} x_url
*/
GameResponse.prototype['x_url'] = undefined;
/**
* @member {module:model/GameResponseRating} rating
*/
GameResponse.prototype['rating'] = undefined;
/**
* @member {String} description
*/
GameResponse.prototype['description'] = undefined;
/**
* @member {String} short_description
*/
GameResponse.prototype['short_description'] = undefined;
/**
* @member {Date} release_date
*/
GameResponse.prototype['release_date'] = undefined;
/**
* @member {String} developer
*/
GameResponse.prototype['developer'] = undefined;
/**
* @member {module:model/GameResponsePlaytime} playtime
*/
GameResponse.prototype['playtime'] = undefined;
/**
* @member {Array.<module:model/GameResponsePlatformsInner>} platforms
*/
GameResponse.prototype['platforms'] = undefined;
/**
* @member {Array.<String>} tags
*/
GameResponse.prototype['tags'] = undefined;
/**
* @member {Array.<module:model/GameResponsePlatformsInner>} genres
*/
GameResponse.prototype['genres'] = undefined;
/**
* @member {String} genre
*/
GameResponse.prototype['genre'] = undefined;
/**
* @member {Array.<module:model/GameResponsePlatformsInner>} themes
*/
GameResponse.prototype['themes'] = undefined;
/**
* @member {Boolean} adult_only
*/
GameResponse.prototype['adult_only'] = undefined;
/**
* @member {Array.<module:model/GameResponsePlatformsInner>} play_modes
*/
GameResponse.prototype['play_modes'] = undefined;
/**
* @member {Array.<String>} screenshots
*/
GameResponse.prototype['screenshots'] = undefined;
/**
* @member {Array.<String>} videos
*/
GameResponse.prototype['videos'] = undefined;
/**
* @member {Array.<module:model/GameResponseOffersInner>} offers
*/
GameResponse.prototype['offers'] = undefined;
/**
* @member {Array.<module:model/GameResponseOfficialStoresInner>} official_stores
*/
GameResponse.prototype['official_stores'] = undefined;
/**
* @member {String} micro_trailer
*/
GameResponse.prototype['micro_trailer'] = undefined;
export default GameResponse;