/**
* 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.
*/
package co.gamebrain;
import co.gamebrain.client.ApiInvoker;
import co.gamebrain.client.ApiException;
import co.gamebrain.client.Pair;
import co.gamebrain.client.model.*;
import java.util.*;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import co.gamebrain.client.model.GameNewsResponse;
import co.gamebrain.client.model.GameResponse;
import co.gamebrain.client.model.SearchResponse;
import co.gamebrain.client.model.SearchSuggestionResponse;
import co.gamebrain.client.model.SimilarGamesResponse;
import org.apache.http.HttpEntity;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
public class DefaultApi {
String basePath = "https://api.gamebrain.co/v1";
ApiInvoker apiInvoker = ApiInvoker.getInstance();
public void addHeader(String key, String value) {
getInvoker().addDefaultHeader(key, value);
}
public ApiInvoker getInvoker() {
return apiInvoker;
}
public void setBasePath(String basePath) {
this.basePath = basePath;
}
public String getBasePath() {
return basePath;
}
/**
* 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.
* @return GameResponse
*/
public GameResponse detail (Integer id, String apiKey) throws TimeoutException, ExecutionException, InterruptedException, ApiException {
Object postBody = null;
// verify the required parameter 'id' is set
if (id == null) {
VolleyError error = new VolleyError("Missing the required parameter 'id' when calling detail",
new ApiException(400, "Missing the required parameter 'id' when calling detail"));
}
// verify the required parameter 'apiKey' is set
if (apiKey == null) {
VolleyError error = new VolleyError("Missing the required parameter 'apiKey' when calling detail",
new ApiException(400, "Missing the required parameter 'apiKey' when calling detail"));
}
// create path and map variables
String path = "/games/{id}".replaceAll("\\{" + "id" + "\\}", apiInvoker.escapeString(id.toString()));
// query params
List<Pair> queryParams = new ArrayList<Pair>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
queryParams.addAll(ApiInvoker.parameterToPairs("", "api-key", apiKey));
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create();
HttpEntity httpEntity = localVarBuilder.build();
postBody = httpEntity;
} else {
// normal form params
}
String[] authNames = new String[] { "apiKey", "headerApiKey" };
try {
String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames);
if (localVarResponse != null) {
return (GameResponse) ApiInvoker.deserialize(localVarResponse, "", GameResponse.class);
} else {
return null;
}
} catch (ApiException ex) {
throw ex;
} catch (InterruptedException ex) {
throw ex;
} catch (ExecutionException ex) {
if (ex.getCause() instanceof VolleyError) {
VolleyError volleyError = (VolleyError)ex.getCause();
if (volleyError.networkResponse != null) {
throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage());
}
}
throw ex;
} catch (TimeoutException ex) {
throw ex;
}
}
/**
* 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.
*/
public void detail (Integer id, String apiKey, final Response.Listener<GameResponse> responseListener, final Response.ErrorListener errorListener) {
Object postBody = null;
// verify the required parameter 'id' is set
if (id == null) {
VolleyError error = new VolleyError("Missing the required parameter 'id' when calling detail",
new ApiException(400, "Missing the required parameter 'id' when calling detail"));
}
// verify the required parameter 'apiKey' is set
if (apiKey == null) {
VolleyError error = new VolleyError("Missing the required parameter 'apiKey' when calling detail",
new ApiException(400, "Missing the required parameter 'apiKey' when calling detail"));
}
// create path and map variables
String path = "/games/{id}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "id" + "\\}", apiInvoker.escapeString(id.toString()));
// query params
List<Pair> queryParams = new ArrayList<Pair>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
queryParams.addAll(ApiInvoker.parameterToPairs("", "api-key", apiKey));
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create();
HttpEntity httpEntity = localVarBuilder.build();
postBody = httpEntity;
} else {
// normal form params
}
String[] authNames = new String[] { "apiKey", "headerApiKey" };
try {
apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames,
new Response.Listener<String>() {
@Override
public void onResponse(String localVarResponse) {
try {
responseListener.onResponse((GameResponse) ApiInvoker.deserialize(localVarResponse, "", GameResponse.class));
} catch (ApiException exception) {
errorListener.onErrorResponse(new VolleyError(exception));
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
errorListener.onErrorResponse(error);
}
});
} catch (ApiException ex) {
errorListener.onErrorResponse(new VolleyError(ex));
}
}
/**
* Get Game News
* Get news related to the given game.
* @param id
* @param offset
* @param limit
* @param apiKey
* @return GameNewsResponse
*/
public GameNewsResponse news (Integer id, Integer offset, Integer limit, String apiKey) throws TimeoutException, ExecutionException, InterruptedException, ApiException {
Object postBody = null;
// verify the required parameter 'id' is set
if (id == null) {
VolleyError error = new VolleyError("Missing the required parameter 'id' when calling news",
new ApiException(400, "Missing the required parameter 'id' when calling news"));
}
// verify the required parameter 'offset' is set
if (offset == null) {
VolleyError error = new VolleyError("Missing the required parameter 'offset' when calling news",
new ApiException(400, "Missing the required parameter 'offset' when calling news"));
}
// verify the required parameter 'limit' is set
if (limit == null) {
VolleyError error = new VolleyError("Missing the required parameter 'limit' when calling news",
new ApiException(400, "Missing the required parameter 'limit' when calling news"));
}
// verify the required parameter 'apiKey' is set
if (apiKey == null) {
VolleyError error = new VolleyError("Missing the required parameter 'apiKey' when calling news",
new ApiException(400, "Missing the required parameter 'apiKey' when calling news"));
}
// create path and map variables
String path = "/games/{id}/news".replaceAll("\\{" + "id" + "\\}", apiInvoker.escapeString(id.toString()));
// query params
List<Pair> queryParams = new ArrayList<Pair>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
queryParams.addAll(ApiInvoker.parameterToPairs("", "offset", offset));
queryParams.addAll(ApiInvoker.parameterToPairs("", "limit", limit));
queryParams.addAll(ApiInvoker.parameterToPairs("", "api-key", apiKey));
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create();
HttpEntity httpEntity = localVarBuilder.build();
postBody = httpEntity;
} else {
// normal form params
}
String[] authNames = new String[] { "apiKey", "headerApiKey" };
try {
String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames);
if (localVarResponse != null) {
return (GameNewsResponse) ApiInvoker.deserialize(localVarResponse, "", GameNewsResponse.class);
} else {
return null;
}
} catch (ApiException ex) {
throw ex;
} catch (InterruptedException ex) {
throw ex;
} catch (ExecutionException ex) {
if (ex.getCause() instanceof VolleyError) {
VolleyError volleyError = (VolleyError)ex.getCause();
if (volleyError.networkResponse != null) {
throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage());
}
}
throw ex;
} catch (TimeoutException ex) {
throw ex;
}
}
/**
* Get Game News
* Get news related to the given game.
* @param id * @param offset * @param limit * @param apiKey
*/
public void news (Integer id, Integer offset, Integer limit, String apiKey, final Response.Listener<GameNewsResponse> responseListener, final Response.ErrorListener errorListener) {
Object postBody = null;
// verify the required parameter 'id' is set
if (id == null) {
VolleyError error = new VolleyError("Missing the required parameter 'id' when calling news",
new ApiException(400, "Missing the required parameter 'id' when calling news"));
}
// verify the required parameter 'offset' is set
if (offset == null) {
VolleyError error = new VolleyError("Missing the required parameter 'offset' when calling news",
new ApiException(400, "Missing the required parameter 'offset' when calling news"));
}
// verify the required parameter 'limit' is set
if (limit == null) {
VolleyError error = new VolleyError("Missing the required parameter 'limit' when calling news",
new ApiException(400, "Missing the required parameter 'limit' when calling news"));
}
// verify the required parameter 'apiKey' is set
if (apiKey == null) {
VolleyError error = new VolleyError("Missing the required parameter 'apiKey' when calling news",
new ApiException(400, "Missing the required parameter 'apiKey' when calling news"));
}
// create path and map variables
String path = "/games/{id}/news".replaceAll("\\{format\\}","json").replaceAll("\\{" + "id" + "\\}", apiInvoker.escapeString(id.toString()));
// query params
List<Pair> queryParams = new ArrayList<Pair>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
queryParams.addAll(ApiInvoker.parameterToPairs("", "offset", offset));
queryParams.addAll(ApiInvoker.parameterToPairs("", "limit", limit));
queryParams.addAll(ApiInvoker.parameterToPairs("", "api-key", apiKey));
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create();
HttpEntity httpEntity = localVarBuilder.build();
postBody = httpEntity;
} else {
// normal form params
}
String[] authNames = new String[] { "apiKey", "headerApiKey" };
try {
apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames,
new Response.Listener<String>() {
@Override
public void onResponse(String localVarResponse) {
try {
responseListener.onResponse((GameNewsResponse) ApiInvoker.deserialize(localVarResponse, "", GameNewsResponse.class));
} catch (ApiException exception) {
errorListener.onErrorResponse(new VolleyError(exception));
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
errorListener.onErrorResponse(error);
}
});
} catch (ApiException ex) {
errorListener.onErrorResponse(new VolleyError(ex));
}
}
/**
* 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. Between 0 and 1000.
* @param limit The maximum number of results to return between 1 and 10.
* @param filters JSON array of filter objects to apply to the search.
* @param sort The field by which to sort the results, either computed_rating, price, or release_date
* @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.
* @return SearchResponse
*/
public SearchResponse search (String query, Integer offset, Integer limit, String filters, String sort, String sortOrder, Boolean generateFilterOptions, String apiKey) throws TimeoutException, ExecutionException, InterruptedException, ApiException {
Object postBody = null;
// verify the required parameter 'query' is set
if (query == null) {
VolleyError error = new VolleyError("Missing the required parameter 'query' when calling search",
new ApiException(400, "Missing the required parameter 'query' when calling search"));
}
// verify the required parameter 'offset' is set
if (offset == null) {
VolleyError error = new VolleyError("Missing the required parameter 'offset' when calling search",
new ApiException(400, "Missing the required parameter 'offset' when calling search"));
}
// verify the required parameter 'limit' is set
if (limit == null) {
VolleyError error = new VolleyError("Missing the required parameter 'limit' when calling search",
new ApiException(400, "Missing the required parameter 'limit' when calling search"));
}
// verify the required parameter 'filters' is set
if (filters == null) {
VolleyError error = new VolleyError("Missing the required parameter 'filters' when calling search",
new ApiException(400, "Missing the required parameter 'filters' when calling search"));
}
// verify the required parameter 'sort' is set
if (sort == null) {
VolleyError error = new VolleyError("Missing the required parameter 'sort' when calling search",
new ApiException(400, "Missing the required parameter 'sort' when calling search"));
}
// verify the required parameter 'sortOrder' is set
if (sortOrder == null) {
VolleyError error = new VolleyError("Missing the required parameter 'sortOrder' when calling search",
new ApiException(400, "Missing the required parameter 'sortOrder' when calling search"));
}
// verify the required parameter 'generateFilterOptions' is set
if (generateFilterOptions == null) {
VolleyError error = new VolleyError("Missing the required parameter 'generateFilterOptions' when calling search",
new ApiException(400, "Missing the required parameter 'generateFilterOptions' when calling search"));
}
// verify the required parameter 'apiKey' is set
if (apiKey == null) {
VolleyError error = new VolleyError("Missing the required parameter 'apiKey' when calling search",
new ApiException(400, "Missing the required parameter 'apiKey' when calling search"));
}
// create path and map variables
String path = "/games";
// query params
List<Pair> queryParams = new ArrayList<Pair>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
queryParams.addAll(ApiInvoker.parameterToPairs("", "query", query));
queryParams.addAll(ApiInvoker.parameterToPairs("", "offset", offset));
queryParams.addAll(ApiInvoker.parameterToPairs("", "limit", limit));
queryParams.addAll(ApiInvoker.parameterToPairs("", "filters", filters));
queryParams.addAll(ApiInvoker.parameterToPairs("", "sort", sort));
queryParams.addAll(ApiInvoker.parameterToPairs("", "sort-order", sortOrder));
queryParams.addAll(ApiInvoker.parameterToPairs("", "generate-filter-options", generateFilterOptions));
queryParams.addAll(ApiInvoker.parameterToPairs("", "api-key", apiKey));
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create();
HttpEntity httpEntity = localVarBuilder.build();
postBody = httpEntity;
} else {
// normal form params
}
String[] authNames = new String[] { "apiKey", "headerApiKey" };
try {
String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames);
if (localVarResponse != null) {
return (SearchResponse) ApiInvoker.deserialize(localVarResponse, "", SearchResponse.class);
} else {
return null;
}
} catch (ApiException ex) {
throw ex;
} catch (InterruptedException ex) {
throw ex;
} catch (ExecutionException ex) {
if (ex.getCause() instanceof VolleyError) {
VolleyError volleyError = (VolleyError)ex.getCause();
if (volleyError.networkResponse != null) {
throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage());
}
}
throw ex;
} catch (TimeoutException ex) {
throw ex;
}
}
/**
* 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. Between 0 and 1000. * @param limit The maximum number of results to return between 1 and 10. * @param filters JSON array of filter objects to apply to the search. * @param sort The field by which to sort the results, either computed_rating, price, or release_date * @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.
*/
public void search (String query, Integer offset, Integer limit, String filters, String sort, String sortOrder, Boolean generateFilterOptions, String apiKey, final Response.Listener<SearchResponse> responseListener, final Response.ErrorListener errorListener) {
Object postBody = null;
// verify the required parameter 'query' is set
if (query == null) {
VolleyError error = new VolleyError("Missing the required parameter 'query' when calling search",
new ApiException(400, "Missing the required parameter 'query' when calling search"));
}
// verify the required parameter 'offset' is set
if (offset == null) {
VolleyError error = new VolleyError("Missing the required parameter 'offset' when calling search",
new ApiException(400, "Missing the required parameter 'offset' when calling search"));
}
// verify the required parameter 'limit' is set
if (limit == null) {
VolleyError error = new VolleyError("Missing the required parameter 'limit' when calling search",
new ApiException(400, "Missing the required parameter 'limit' when calling search"));
}
// verify the required parameter 'filters' is set
if (filters == null) {
VolleyError error = new VolleyError("Missing the required parameter 'filters' when calling search",
new ApiException(400, "Missing the required parameter 'filters' when calling search"));
}
// verify the required parameter 'sort' is set
if (sort == null) {
VolleyError error = new VolleyError("Missing the required parameter 'sort' when calling search",
new ApiException(400, "Missing the required parameter 'sort' when calling search"));
}
// verify the required parameter 'sortOrder' is set
if (sortOrder == null) {
VolleyError error = new VolleyError("Missing the required parameter 'sortOrder' when calling search",
new ApiException(400, "Missing the required parameter 'sortOrder' when calling search"));
}
// verify the required parameter 'generateFilterOptions' is set
if (generateFilterOptions == null) {
VolleyError error = new VolleyError("Missing the required parameter 'generateFilterOptions' when calling search",
new ApiException(400, "Missing the required parameter 'generateFilterOptions' when calling search"));
}
// verify the required parameter 'apiKey' is set
if (apiKey == null) {
VolleyError error = new VolleyError("Missing the required parameter 'apiKey' when calling search",
new ApiException(400, "Missing the required parameter 'apiKey' when calling search"));
}
// create path and map variables
String path = "/games".replaceAll("\\{format\\}","json");
// query params
List<Pair> queryParams = new ArrayList<Pair>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
queryParams.addAll(ApiInvoker.parameterToPairs("", "query", query));
queryParams.addAll(ApiInvoker.parameterToPairs("", "offset", offset));
queryParams.addAll(ApiInvoker.parameterToPairs("", "limit", limit));
queryParams.addAll(ApiInvoker.parameterToPairs("", "filters", filters));
queryParams.addAll(ApiInvoker.parameterToPairs("", "sort", sort));
queryParams.addAll(ApiInvoker.parameterToPairs("", "sort-order", sortOrder));
queryParams.addAll(ApiInvoker.parameterToPairs("", "generate-filter-options", generateFilterOptions));
queryParams.addAll(ApiInvoker.parameterToPairs("", "api-key", apiKey));
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create();
HttpEntity httpEntity = localVarBuilder.build();
postBody = httpEntity;
} else {
// normal form params
}
String[] authNames = new String[] { "apiKey", "headerApiKey" };
try {
apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames,
new Response.Listener<String>() {
@Override
public void onResponse(String localVarResponse) {
try {
responseListener.onResponse((SearchResponse) ApiInvoker.deserialize(localVarResponse, "", SearchResponse.class));
} catch (ApiException exception) {
errorListener.onErrorResponse(new VolleyError(exception));
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
errorListener.onErrorResponse(error);
}
});
} catch (ApiException ex) {
errorListener.onErrorResponse(new VolleyError(ex));
}
}
/**
* Get Similar Games
* Get games that are similar to the given one.
* @param id
* @param limit
* @param apiKey
* @return SimilarGamesResponse
*/
public SimilarGamesResponse similar (Integer id, Integer limit, String apiKey) throws TimeoutException, ExecutionException, InterruptedException, ApiException {
Object postBody = null;
// verify the required parameter 'id' is set
if (id == null) {
VolleyError error = new VolleyError("Missing the required parameter 'id' when calling similar",
new ApiException(400, "Missing the required parameter 'id' when calling similar"));
}
// verify the required parameter 'limit' is set
if (limit == null) {
VolleyError error = new VolleyError("Missing the required parameter 'limit' when calling similar",
new ApiException(400, "Missing the required parameter 'limit' when calling similar"));
}
// verify the required parameter 'apiKey' is set
if (apiKey == null) {
VolleyError error = new VolleyError("Missing the required parameter 'apiKey' when calling similar",
new ApiException(400, "Missing the required parameter 'apiKey' when calling similar"));
}
// create path and map variables
String path = "/games/{id}/similar".replaceAll("\\{" + "id" + "\\}", apiInvoker.escapeString(id.toString()));
// query params
List<Pair> queryParams = new ArrayList<Pair>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
queryParams.addAll(ApiInvoker.parameterToPairs("", "limit", limit));
queryParams.addAll(ApiInvoker.parameterToPairs("", "api-key", apiKey));
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create();
HttpEntity httpEntity = localVarBuilder.build();
postBody = httpEntity;
} else {
// normal form params
}
String[] authNames = new String[] { "apiKey", "headerApiKey" };
try {
String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames);
if (localVarResponse != null) {
return (SimilarGamesResponse) ApiInvoker.deserialize(localVarResponse, "", SimilarGamesResponse.class);
} else {
return null;
}
} catch (ApiException ex) {
throw ex;
} catch (InterruptedException ex) {
throw ex;
} catch (ExecutionException ex) {
if (ex.getCause() instanceof VolleyError) {
VolleyError volleyError = (VolleyError)ex.getCause();
if (volleyError.networkResponse != null) {
throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage());
}
}
throw ex;
} catch (TimeoutException ex) {
throw ex;
}
}
/**
* Get Similar Games
* Get games that are similar to the given one.
* @param id * @param limit * @param apiKey
*/
public void similar (Integer id, Integer limit, String apiKey, final Response.Listener<SimilarGamesResponse> responseListener, final Response.ErrorListener errorListener) {
Object postBody = null;
// verify the required parameter 'id' is set
if (id == null) {
VolleyError error = new VolleyError("Missing the required parameter 'id' when calling similar",
new ApiException(400, "Missing the required parameter 'id' when calling similar"));
}
// verify the required parameter 'limit' is set
if (limit == null) {
VolleyError error = new VolleyError("Missing the required parameter 'limit' when calling similar",
new ApiException(400, "Missing the required parameter 'limit' when calling similar"));
}
// verify the required parameter 'apiKey' is set
if (apiKey == null) {
VolleyError error = new VolleyError("Missing the required parameter 'apiKey' when calling similar",
new ApiException(400, "Missing the required parameter 'apiKey' when calling similar"));
}
// create path and map variables
String path = "/games/{id}/similar".replaceAll("\\{format\\}","json").replaceAll("\\{" + "id" + "\\}", apiInvoker.escapeString(id.toString()));
// query params
List<Pair> queryParams = new ArrayList<Pair>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
queryParams.addAll(ApiInvoker.parameterToPairs("", "limit", limit));
queryParams.addAll(ApiInvoker.parameterToPairs("", "api-key", apiKey));
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create();
HttpEntity httpEntity = localVarBuilder.build();
postBody = httpEntity;
} else {
// normal form params
}
String[] authNames = new String[] { "apiKey", "headerApiKey" };
try {
apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames,
new Response.Listener<String>() {
@Override
public void onResponse(String localVarResponse) {
try {
responseListener.onResponse((SimilarGamesResponse) ApiInvoker.deserialize(localVarResponse, "", SimilarGamesResponse.class));
} catch (ApiException exception) {
errorListener.onErrorResponse(new VolleyError(exception));
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
errorListener.onErrorResponse(error);
}
});
} catch (ApiException ex) {
errorListener.onErrorResponse(new VolleyError(ex));
}
}
/**
* 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.
* @return SearchSuggestionResponse
*/
public SearchSuggestionResponse suggest (String query, Integer limit, String apiKey) throws TimeoutException, ExecutionException, InterruptedException, ApiException {
Object postBody = null;
// verify the required parameter 'query' is set
if (query == null) {
VolleyError error = new VolleyError("Missing the required parameter 'query' when calling suggest",
new ApiException(400, "Missing the required parameter 'query' when calling suggest"));
}
// verify the required parameter 'limit' is set
if (limit == null) {
VolleyError error = new VolleyError("Missing the required parameter 'limit' when calling suggest",
new ApiException(400, "Missing the required parameter 'limit' when calling suggest"));
}
// verify the required parameter 'apiKey' is set
if (apiKey == null) {
VolleyError error = new VolleyError("Missing the required parameter 'apiKey' when calling suggest",
new ApiException(400, "Missing the required parameter 'apiKey' when calling suggest"));
}
// create path and map variables
String path = "/games/suggestions";
// query params
List<Pair> queryParams = new ArrayList<Pair>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
queryParams.addAll(ApiInvoker.parameterToPairs("", "query", query));
queryParams.addAll(ApiInvoker.parameterToPairs("", "limit", limit));
queryParams.addAll(ApiInvoker.parameterToPairs("", "api-key", apiKey));
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create();
HttpEntity httpEntity = localVarBuilder.build();
postBody = httpEntity;
} else {
// normal form params
}
String[] authNames = new String[] { "apiKey", "headerApiKey" };
try {
String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames);
if (localVarResponse != null) {
return (SearchSuggestionResponse) ApiInvoker.deserialize(localVarResponse, "", SearchSuggestionResponse.class);
} else {
return null;
}
} catch (ApiException ex) {
throw ex;
} catch (InterruptedException ex) {
throw ex;
} catch (ExecutionException ex) {
if (ex.getCause() instanceof VolleyError) {
VolleyError volleyError = (VolleyError)ex.getCause();
if (volleyError.networkResponse != null) {
throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage());
}
}
throw ex;
} catch (TimeoutException ex) {
throw ex;
}
}
/**
* 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.
*/
public void suggest (String query, Integer limit, String apiKey, final Response.Listener<SearchSuggestionResponse> responseListener, final Response.ErrorListener errorListener) {
Object postBody = null;
// verify the required parameter 'query' is set
if (query == null) {
VolleyError error = new VolleyError("Missing the required parameter 'query' when calling suggest",
new ApiException(400, "Missing the required parameter 'query' when calling suggest"));
}
// verify the required parameter 'limit' is set
if (limit == null) {
VolleyError error = new VolleyError("Missing the required parameter 'limit' when calling suggest",
new ApiException(400, "Missing the required parameter 'limit' when calling suggest"));
}
// verify the required parameter 'apiKey' is set
if (apiKey == null) {
VolleyError error = new VolleyError("Missing the required parameter 'apiKey' when calling suggest",
new ApiException(400, "Missing the required parameter 'apiKey' when calling suggest"));
}
// create path and map variables
String path = "/games/suggestions".replaceAll("\\{format\\}","json");
// query params
List<Pair> queryParams = new ArrayList<Pair>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
queryParams.addAll(ApiInvoker.parameterToPairs("", "query", query));
queryParams.addAll(ApiInvoker.parameterToPairs("", "limit", limit));
queryParams.addAll(ApiInvoker.parameterToPairs("", "api-key", apiKey));
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create();
HttpEntity httpEntity = localVarBuilder.build();
postBody = httpEntity;
} else {
// normal form params
}
String[] authNames = new String[] { "apiKey", "headerApiKey" };
try {
apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames,
new Response.Listener<String>() {
@Override
public void onResponse(String localVarResponse) {
try {
responseListener.onResponse((SearchSuggestionResponse) ApiInvoker.deserialize(localVarResponse, "", SearchSuggestionResponse.class));
} catch (ApiException exception) {
errorListener.onErrorResponse(new VolleyError(exception));
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
errorListener.onErrorResponse(error);
}
});
} catch (ApiException ex) {
errorListener.onErrorResponse(new VolleyError(ex));
}
}
}