/**
* 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 SearchResponseActiveFilterOptionsInner from './SearchResponseActiveFilterOptionsInner';
import SearchResponseFilterOptionsInner from './SearchResponseFilterOptionsInner';
import SearchResponseResultsInner from './SearchResponseResultsInner';
import SearchResponseSorting from './SearchResponseSorting';
import SearchResponseSortingOptionsInner from './SearchResponseSortingOptionsInner';
/**
* The SearchResponse model module.
* @module model/SearchResponse
* @version 1.0.2
*/
class SearchResponse {
/**
* Constructs a new <code>SearchResponse</code>.
* @alias module:model/SearchResponse
*/
constructor() {
SearchResponse.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>SearchResponse</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/SearchResponse} obj Optional instance to populate.
* @return {module:model/SearchResponse} The populated <code>SearchResponse</code> instance.
*/
static constructFromObject(data, obj) {
if (data) {
obj = obj || new SearchResponse();
if (data.hasOwnProperty('sorting')) {
obj['sorting'] = SearchResponseSorting.constructFromObject(data['sorting']);
}
if (data.hasOwnProperty('active_filter_options')) {
obj['active_filter_options'] = ApiClient.convertToType(data['active_filter_options'], [SearchResponseActiveFilterOptionsInner]);
}
if (data.hasOwnProperty('query')) {
obj['query'] = ApiClient.convertToType(data['query'], 'String');
}
if (data.hasOwnProperty('total_results')) {
obj['total_results'] = ApiClient.convertToType(data['total_results'], 'Number');
}
if (data.hasOwnProperty('limit')) {
obj['limit'] = ApiClient.convertToType(data['limit'], 'Number');
}
if (data.hasOwnProperty('offset')) {
obj['offset'] = ApiClient.convertToType(data['offset'], 'Number');
}
if (data.hasOwnProperty('results')) {
obj['results'] = ApiClient.convertToType(data['results'], [SearchResponseResultsInner]);
}
if (data.hasOwnProperty('filter_options')) {
obj['filter_options'] = ApiClient.convertToType(data['filter_options'], [SearchResponseFilterOptionsInner]);
}
if (data.hasOwnProperty('sorting_options')) {
obj['sorting_options'] = ApiClient.convertToType(data['sorting_options'], [SearchResponseSortingOptionsInner]);
}
}
return obj;
}
/**
* Validates the JSON data with respect to <code>SearchResponse</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>SearchResponse</code>.
*/
static validateJSON(data) {
// validate the optional field `sorting`
if (data['sorting']) { // data not null
SearchResponseSorting.validateJSON(data['sorting']);
}
if (data['active_filter_options']) { // data not null
// ensure the json data is an array
if (!Array.isArray(data['active_filter_options'])) {
throw new Error("Expected the field `active_filter_options` to be an array in the JSON data but got " + data['active_filter_options']);
}
// validate the optional field `active_filter_options` (array)
for (const item of data['active_filter_options']) {
SearchResponseActiveFilterOptionsInner.validateJSON(item);
};
}
// ensure the json data is a string
if (data['query'] && !(typeof data['query'] === 'string' || data['query'] instanceof String)) {
throw new Error("Expected the field `query` to be a primitive type in the JSON string but got " + data['query']);
}
if (data['results']) { // data not null
// ensure the json data is an array
if (!Array.isArray(data['results'])) {
throw new Error("Expected the field `results` to be an array in the JSON data but got " + data['results']);
}
// validate the optional field `results` (array)
for (const item of data['results']) {
SearchResponseResultsInner.validateJSON(item);
};
}
if (data['filter_options']) { // data not null
// ensure the json data is an array
if (!Array.isArray(data['filter_options'])) {
throw new Error("Expected the field `filter_options` to be an array in the JSON data but got " + data['filter_options']);
}
// validate the optional field `filter_options` (array)
for (const item of data['filter_options']) {
SearchResponseFilterOptionsInner.validateJSON(item);
};
}
if (data['sorting_options']) { // data not null
// ensure the json data is an array
if (!Array.isArray(data['sorting_options'])) {
throw new Error("Expected the field `sorting_options` to be an array in the JSON data but got " + data['sorting_options']);
}
// validate the optional field `sorting_options` (array)
for (const item of data['sorting_options']) {
SearchResponseSortingOptionsInner.validateJSON(item);
};
}
return true;
}
}
/**
* @member {module:model/SearchResponseSorting} sorting
*/
SearchResponse.prototype['sorting'] = undefined;
/**
* @member {Array.<module:model/SearchResponseActiveFilterOptionsInner>} active_filter_options
*/
SearchResponse.prototype['active_filter_options'] = undefined;
/**
* @member {String} query
*/
SearchResponse.prototype['query'] = undefined;
/**
* @member {Number} total_results
*/
SearchResponse.prototype['total_results'] = undefined;
/**
* @member {Number} limit
*/
SearchResponse.prototype['limit'] = undefined;
/**
* @member {Number} offset
*/
SearchResponse.prototype['offset'] = undefined;
/**
* @member {Array.<module:model/SearchResponseResultsInner>} results
*/
SearchResponse.prototype['results'] = undefined;
/**
* @member {Array.<module:model/SearchResponseFilterOptionsInner>} filter_options
*/
SearchResponse.prototype['filter_options'] = undefined;
/**
* @member {Array.<module:model/SearchResponseSortingOptionsInner>} sorting_options
*/
SearchResponse.prototype['sorting_options'] = undefined;
export default SearchResponse;