/**
* 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.
*/
/* tslint:disable:no-unused-variable member-ordering */
import { Inject, Injectable, Optional } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams,
HttpResponse, HttpEvent, HttpParameterCodec, HttpContext
} from '@angular/common/http';
import { CustomHttpParameterCodec } from '../encoder';
import { Observable } from 'rxjs';
// @ts-ignore
import { GameResponse } from '../model/gameResponse';
// @ts-ignore
import { SearchResponse } from '../model/searchResponse';
// @ts-ignore
import { SearchSuggestionResponse } from '../model/searchSuggestionResponse';
// @ts-ignore
import { SimilarGamesResponse } from '../model/similarGamesResponse';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
import { Configuration } from '../configuration';
@Injectable({
providedIn: 'root'
})
export class DefaultService {
protected basePath = 'https://api.gamebrain.co/v1';
public defaultHeaders = new HttpHeaders();
public configuration = new Configuration();
public encoder: HttpParameterCodec;
constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string|string[], @Optional() configuration: Configuration) {
if (configuration) {
this.configuration = configuration;
}
if (typeof this.configuration.basePath !== 'string') {
const firstBasePath = Array.isArray(basePath) ? basePath[0] : undefined;
if (firstBasePath != undefined) {
basePath = firstBasePath;
}
if (typeof basePath !== 'string') {
basePath = this.basePath;
}
this.configuration.basePath = basePath;
}
this.encoder = this.configuration.encoder || new CustomHttpParameterCodec();
}
// @ts-ignore
private addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams {
if (typeof value === "object" && value instanceof Date === false) {
httpParams = this.addToHttpParamsRecursive(httpParams, value);
} else {
httpParams = this.addToHttpParamsRecursive(httpParams, value, key);
}
return httpParams;
}
private addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string): HttpParams {
if (value == null) {
return httpParams;
}
if (typeof value === "object") {
if (Array.isArray(value)) {
(value as any[]).forEach( elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key));
} else if (value instanceof Date) {
if (key != null) {
httpParams = httpParams.append(key, (value as Date).toISOString().substring(0, 10));
} else {
throw Error("key may not be null if value is Date");
}
} else {
Object.keys(value).forEach( k => httpParams = this.addToHttpParamsRecursive(
httpParams, value[k], key != null ? `${key}.${k}` : k));
}
} else if (key != null) {
httpParams = httpParams.append(key, value);
} else {
throw Error("key may not be null if value is not object or array");
}
return httpParams;
}
/**
* Get Game Details
* Get all the details about a game given its id. Details include screenshots, ratings, release dates, videos, description, tags, and much more.
* @param id The unique identifier of the game.
* @param apiKey Your API key for authentication.
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public detail(id: number, apiKey: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<GameResponse>;
public detail(id: number, apiKey: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<GameResponse>>;
public detail(id: number, apiKey: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<GameResponse>>;
public detail(id: number, apiKey: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling detail.');
}
if (apiKey === null || apiKey === undefined) {
throw new Error('Required parameter apiKey was null or undefined when calling detail.');
}
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
if (apiKey !== undefined && apiKey !== null) {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>apiKey, 'api-key');
}
let localVarHeaders = this.defaultHeaders;
let localVarCredential: string | undefined;
// authentication (apiKey) required
localVarCredential = this.configuration.lookupCredential('apiKey');
if (localVarCredential) {
localVarQueryParameters = localVarQueryParameters.set('api-key', localVarCredential);
}
// authentication (headerApiKey) required
localVarCredential = this.configuration.lookupCredential('headerApiKey');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('x-api-key', localVarCredential);
}
let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
if (localVarHttpHeaderAcceptSelected === undefined) {
// to determine the Accept header
const httpHeaderAccepts: string[] = [
'application/json'
];
localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
}
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
let localVarHttpContext: HttpContext | undefined = options && options.context;
if (localVarHttpContext === undefined) {
localVarHttpContext = new HttpContext();
}
let localVarTransferCache: boolean | undefined = options && options.transferCache;
if (localVarTransferCache === undefined) {
localVarTransferCache = true;
}
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/games/${this.configuration.encodeParam({name: "id", value: id, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int32"})}`;
return this.httpClient.request<GameResponse>('get', `${this.configuration.basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: localVarHeaders,
observe: observe,
transferCache: localVarTransferCache,
reportProgress: reportProgress
}
);
}
/**
* Search Games
* Search hundreds of thousands of video games from over 70 platforms. The query can be a game name, a platform, a genre, or any combination
* @param query The search query, e.g., game name, platform, genre, or any combination.
* @param offset The number of results to skip before starting to collect the result set.
* @param limit The maximum number of results to return.
* @param filters JSON array of filter objects to apply to the search.
* @param sort The field by which to sort the results.
* @param sortOrder The sort order: \'asc\' for ascending or \'desc\' for descending.
* @param generateFilterOptions Whether to generate filter options in the response.
* @param apiKey Your API key for authentication.
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public search(query: string, offset: number, limit: number, filters: string, sort: string, sortOrder: string, generateFilterOptions: boolean, apiKey: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<SearchResponse>;
public search(query: string, offset: number, limit: number, filters: string, sort: string, sortOrder: string, generateFilterOptions: boolean, apiKey: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<SearchResponse>>;
public search(query: string, offset: number, limit: number, filters: string, sort: string, sortOrder: string, generateFilterOptions: boolean, apiKey: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<SearchResponse>>;
public search(query: string, offset: number, limit: number, filters: string, sort: string, sortOrder: string, generateFilterOptions: boolean, apiKey: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (query === null || query === undefined) {
throw new Error('Required parameter query was null or undefined when calling search.');
}
if (offset === null || offset === undefined) {
throw new Error('Required parameter offset was null or undefined when calling search.');
}
if (limit === null || limit === undefined) {
throw new Error('Required parameter limit was null or undefined when calling search.');
}
if (filters === null || filters === undefined) {
throw new Error('Required parameter filters was null or undefined when calling search.');
}
if (sort === null || sort === undefined) {
throw new Error('Required parameter sort was null or undefined when calling search.');
}
if (sortOrder === null || sortOrder === undefined) {
throw new Error('Required parameter sortOrder was null or undefined when calling search.');
}
if (generateFilterOptions === null || generateFilterOptions === undefined) {
throw new Error('Required parameter generateFilterOptions was null or undefined when calling search.');
}
if (apiKey === null || apiKey === undefined) {
throw new Error('Required parameter apiKey was null or undefined when calling search.');
}
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
if (query !== undefined && query !== null) {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>query, 'query');
}
if (offset !== undefined && offset !== null) {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>offset, 'offset');
}
if (limit !== undefined && limit !== null) {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>limit, 'limit');
}
if (filters !== undefined && filters !== null) {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>filters, 'filters');
}
if (sort !== undefined && sort !== null) {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>sort, 'sort');
}
if (sortOrder !== undefined && sortOrder !== null) {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>sortOrder, 'sort-order');
}
if (generateFilterOptions !== undefined && generateFilterOptions !== null) {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>generateFilterOptions, 'generate-filter-options');
}
if (apiKey !== undefined && apiKey !== null) {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>apiKey, 'api-key');
}
let localVarHeaders = this.defaultHeaders;
let localVarCredential: string | undefined;
// authentication (apiKey) required
localVarCredential = this.configuration.lookupCredential('apiKey');
if (localVarCredential) {
localVarQueryParameters = localVarQueryParameters.set('api-key', localVarCredential);
}
// authentication (headerApiKey) required
localVarCredential = this.configuration.lookupCredential('headerApiKey');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('x-api-key', localVarCredential);
}
let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
if (localVarHttpHeaderAcceptSelected === undefined) {
// to determine the Accept header
const httpHeaderAccepts: string[] = [
'application/json'
];
localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
}
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
let localVarHttpContext: HttpContext | undefined = options && options.context;
if (localVarHttpContext === undefined) {
localVarHttpContext = new HttpContext();
}
let localVarTransferCache: boolean | undefined = options && options.transferCache;
if (localVarTransferCache === undefined) {
localVarTransferCache = true;
}
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/games`;
return this.httpClient.request<SearchResponse>('get', `${this.configuration.basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: localVarHeaders,
observe: observe,
transferCache: localVarTransferCache,
reportProgress: reportProgress
}
);
}
/**
* Get Similar Games
* Get games that are similar to the given one.
* @param id
* @param limit
* @param apiKey
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public similar(id: number, limit: number, apiKey: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<SimilarGamesResponse>;
public similar(id: number, limit: number, apiKey: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<SimilarGamesResponse>>;
public similar(id: number, limit: number, apiKey: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<SimilarGamesResponse>>;
public similar(id: number, limit: number, apiKey: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling similar.');
}
if (limit === null || limit === undefined) {
throw new Error('Required parameter limit was null or undefined when calling similar.');
}
if (apiKey === null || apiKey === undefined) {
throw new Error('Required parameter apiKey was null or undefined when calling similar.');
}
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
if (limit !== undefined && limit !== null) {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>limit, 'limit');
}
if (apiKey !== undefined && apiKey !== null) {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>apiKey, 'api-key');
}
let localVarHeaders = this.defaultHeaders;
let localVarCredential: string | undefined;
// authentication (apiKey) required
localVarCredential = this.configuration.lookupCredential('apiKey');
if (localVarCredential) {
localVarQueryParameters = localVarQueryParameters.set('api-key', localVarCredential);
}
// authentication (headerApiKey) required
localVarCredential = this.configuration.lookupCredential('headerApiKey');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('x-api-key', localVarCredential);
}
let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
if (localVarHttpHeaderAcceptSelected === undefined) {
// to determine the Accept header
const httpHeaderAccepts: string[] = [
'application/json'
];
localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
}
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
let localVarHttpContext: HttpContext | undefined = options && options.context;
if (localVarHttpContext === undefined) {
localVarHttpContext = new HttpContext();
}
let localVarTransferCache: boolean | undefined = options && options.transferCache;
if (localVarTransferCache === undefined) {
localVarTransferCache = true;
}
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/games/${this.configuration.encodeParam({name: "id", value: id, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int32"})}/similar`;
return this.httpClient.request<SimilarGamesResponse>('get', `${this.configuration.basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: localVarHeaders,
observe: observe,
transferCache: localVarTransferCache,
reportProgress: reportProgress
}
);
}
/**
* Get Game Suggestions
* Get game suggestions based on (partial) search queries. For example, the query \'gt\' will return games like GTA.
* @param query The partial search query to get suggestions for.
* @param limit The maximum number of suggestions to return.
* @param apiKey Your API key for authentication.
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public suggest(query: string, limit: number, apiKey: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<SearchSuggestionResponse>;
public suggest(query: string, limit: number, apiKey: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<SearchSuggestionResponse>>;
public suggest(query: string, limit: number, apiKey: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<SearchSuggestionResponse>>;
public suggest(query: string, limit: number, apiKey: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (query === null || query === undefined) {
throw new Error('Required parameter query was null or undefined when calling suggest.');
}
if (limit === null || limit === undefined) {
throw new Error('Required parameter limit was null or undefined when calling suggest.');
}
if (apiKey === null || apiKey === undefined) {
throw new Error('Required parameter apiKey was null or undefined when calling suggest.');
}
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
if (query !== undefined && query !== null) {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>query, 'query');
}
if (limit !== undefined && limit !== null) {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>limit, 'limit');
}
if (apiKey !== undefined && apiKey !== null) {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>apiKey, 'api-key');
}
let localVarHeaders = this.defaultHeaders;
let localVarCredential: string | undefined;
// authentication (apiKey) required
localVarCredential = this.configuration.lookupCredential('apiKey');
if (localVarCredential) {
localVarQueryParameters = localVarQueryParameters.set('api-key', localVarCredential);
}
// authentication (headerApiKey) required
localVarCredential = this.configuration.lookupCredential('headerApiKey');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('x-api-key', localVarCredential);
}
let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
if (localVarHttpHeaderAcceptSelected === undefined) {
// to determine the Accept header
const httpHeaderAccepts: string[] = [
'application/json'
];
localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
}
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
let localVarHttpContext: HttpContext | undefined = options && options.context;
if (localVarHttpContext === undefined) {
localVarHttpContext = new HttpContext();
}
let localVarTransferCache: boolean | undefined = options && options.transferCache;
if (localVarTransferCache === undefined) {
localVarTransferCache = true;
}
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/games/suggestions`;
return this.httpClient.request<SearchSuggestionResponse>('get', `${this.configuration.basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: localVarHeaders,
observe: observe,
transferCache: localVarTransferCache,
reportProgress: reportProgress
}
);
}
}