/**
* 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';
/**
* The GameNewsItem model module.
* @module model/GameNewsItem
* @version 1.0.2
*/
class GameNewsItem {
/**
* Constructs a new <code>GameNewsItem</code>.
* @alias module:model/GameNewsItem
* @param title {String}
* @param url {String}
* @param source {String}
* @param published {Date}
*/
constructor(title, url, source, published) {
GameNewsItem.initialize(this, title, url, source, published);
}
/**
* 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, title, url, source, published) {
obj['title'] = title;
obj['url'] = url;
obj['source'] = source;
obj['published'] = published;
}
/**
* Constructs a <code>GameNewsItem</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/GameNewsItem} obj Optional instance to populate.
* @return {module:model/GameNewsItem} The populated <code>GameNewsItem</code> instance.
*/
static constructFromObject(data, obj) {
if (data) {
obj = obj || new GameNewsItem();
if (data.hasOwnProperty('title')) {
obj['title'] = ApiClient.convertToType(data['title'], 'String');
}
if (data.hasOwnProperty('url')) {
obj['url'] = ApiClient.convertToType(data['url'], 'String');
}
if (data.hasOwnProperty('source')) {
obj['source'] = ApiClient.convertToType(data['source'], 'String');
}
if (data.hasOwnProperty('image')) {
obj['image'] = ApiClient.convertToType(data['image'], 'String');
}
if (data.hasOwnProperty('published')) {
obj['published'] = ApiClient.convertToType(data['published'], 'Date');
}
}
return obj;
}
/**
* Validates the JSON data with respect to <code>GameNewsItem</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>GameNewsItem</code>.
*/
static validateJSON(data) {
// check to make sure all required properties are present in the JSON string
for (const property of GameNewsItem.RequiredProperties) {
if (!data.hasOwnProperty(property)) {
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
}
}
// ensure the json data is a string
if (data['title'] && !(typeof data['title'] === 'string' || data['title'] instanceof String)) {
throw new Error("Expected the field `title` to be a primitive type in the JSON string but got " + data['title']);
}
// ensure the json data is a string
if (data['url'] && !(typeof data['url'] === 'string' || data['url'] instanceof String)) {
throw new Error("Expected the field `url` to be a primitive type in the JSON string but got " + data['url']);
}
// ensure the json data is a string
if (data['source'] && !(typeof data['source'] === 'string' || data['source'] instanceof String)) {
throw new Error("Expected the field `source` to be a primitive type in the JSON string but got " + data['source']);
}
// 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']);
}
return true;
}
}
GameNewsItem.RequiredProperties = ["title", "url", "source", "published"];
/**
* @member {String} title
*/
GameNewsItem.prototype['title'] = undefined;
/**
* @member {String} url
*/
GameNewsItem.prototype['url'] = undefined;
/**
* @member {String} source
*/
GameNewsItem.prototype['source'] = undefined;
/**
* @member {String} image
*/
GameNewsItem.prototype['image'] = undefined;
/**
* @member {Date} published
*/
GameNewsItem.prototype['published'] = undefined;
export default GameNewsItem;