=begin
#GameBrain API
#GameBrain API
The version of the OpenAPI document: 1.0.1
Contact: mail@gamebrain.co
Generated by: https://openapi-generator.tech
Generator version: 7.8.0-SNAPSHOT
=end
require 'cgi'
module OpenapiClient
class DefaultApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# 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 [Integer] The unique identifier of the game.
# @param api_key [String] Your API key for authentication.
# @param [Hash] opts the optional parameters
# @return [GameResponse]
def detail(id, api_key, opts = {})
data, _status_code, _headers = detail_with_http_info(id, api_key, opts)
data
end
# 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 [Integer] The unique identifier of the game.
# @param api_key [String] Your API key for authentication.
# @param [Hash] opts the optional parameters
# @return [Array<(GameResponse, Integer, Hash)>] GameResponse data, response status code and response headers
def detail_with_http_info(id, api_key, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: DefaultApi.detail ...'
end
# verify the required parameter 'id' is set
if @api_client.config.client_side_validation && id.nil?
fail ArgumentError, "Missing the required parameter 'id' when calling DefaultApi.detail"
end
# verify the required parameter 'api_key' is set
if @api_client.config.client_side_validation && api_key.nil?
fail ArgumentError, "Missing the required parameter 'api_key' when calling DefaultApi.detail"
end
if @api_client.config.client_side_validation && api_key.to_s.length > 300
fail ArgumentError, 'invalid value for "api_key" when calling DefaultApi.detail, the character length must be smaller than or equal to 300.'
end
pattern = Regexp.new(/.*/)
if @api_client.config.client_side_validation && api_key !~ pattern
fail ArgumentError, "invalid value for 'api_key' when calling DefaultApi.detail, must conform to the pattern #{pattern}."
end
# resource path
local_var_path = '/games/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'api-key'] = api_key
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'GameResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['apiKey', 'headerApiKey']
new_options = opts.merge(
:operation => :"DefaultApi.detail",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: DefaultApi#detail\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get Game News
# Get news related to the given game.
# @param id [Integer]
# @param offset [Integer]
# @param limit [Integer]
# @param api_key [String]
# @param [Hash] opts the optional parameters
# @return [GameNewsResponse]
def news(id, offset, limit, api_key, opts = {})
data, _status_code, _headers = news_with_http_info(id, offset, limit, api_key, opts)
data
end
# Get Game News
# Get news related to the given game.
# @param id [Integer]
# @param offset [Integer]
# @param limit [Integer]
# @param api_key [String]
# @param [Hash] opts the optional parameters
# @return [Array<(GameNewsResponse, Integer, Hash)>] GameNewsResponse data, response status code and response headers
def news_with_http_info(id, offset, limit, api_key, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: DefaultApi.news ...'
end
# verify the required parameter 'id' is set
if @api_client.config.client_side_validation && id.nil?
fail ArgumentError, "Missing the required parameter 'id' when calling DefaultApi.news"
end
# verify the required parameter 'offset' is set
if @api_client.config.client_side_validation && offset.nil?
fail ArgumentError, "Missing the required parameter 'offset' when calling DefaultApi.news"
end
# verify the required parameter 'limit' is set
if @api_client.config.client_side_validation && limit.nil?
fail ArgumentError, "Missing the required parameter 'limit' when calling DefaultApi.news"
end
# verify the required parameter 'api_key' is set
if @api_client.config.client_side_validation && api_key.nil?
fail ArgumentError, "Missing the required parameter 'api_key' when calling DefaultApi.news"
end
if @api_client.config.client_side_validation && api_key.to_s.length > 300
fail ArgumentError, 'invalid value for "api_key" when calling DefaultApi.news, the character length must be smaller than or equal to 300.'
end
pattern = Regexp.new(/.*/)
if @api_client.config.client_side_validation && api_key !~ pattern
fail ArgumentError, "invalid value for 'api_key' when calling DefaultApi.news, must conform to the pattern #{pattern}."
end
# resource path
local_var_path = '/games/{id}/news'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'offset'] = offset
query_params[:'limit'] = limit
query_params[:'api-key'] = api_key
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'GameNewsResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['apiKey', 'headerApiKey']
new_options = opts.merge(
:operation => :"DefaultApi.news",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: DefaultApi#news\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# 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 [String] The search query, e.g., game name, platform, genre, or any combination.
# @param offset [Integer] The number of results to skip before starting to collect the result set. Between 0 and 1000.
# @param limit [Integer] The maximum number of results to return between 1 and 10.
# @param filters [String] JSON array of filter objects to apply to the search.
# @param sort [String] The field by which to sort the results, either computed_rating, price, or release_date
# @param sort_order [String] The sort order: 'asc' for ascending or 'desc' for descending.
# @param generate_filter_options [Boolean] Whether to generate filter options in the response.
# @param api_key [String] Your API key for authentication.
# @param [Hash] opts the optional parameters
# @return [SearchResponse]
def search(query, offset, limit, filters, sort, sort_order, generate_filter_options, api_key, opts = {})
data, _status_code, _headers = search_with_http_info(query, offset, limit, filters, sort, sort_order, generate_filter_options, api_key, opts)
data
end
# 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 [String] The search query, e.g., game name, platform, genre, or any combination.
# @param offset [Integer] The number of results to skip before starting to collect the result set. Between 0 and 1000.
# @param limit [Integer] The maximum number of results to return between 1 and 10.
# @param filters [String] JSON array of filter objects to apply to the search.
# @param sort [String] The field by which to sort the results, either computed_rating, price, or release_date
# @param sort_order [String] The sort order: 'asc' for ascending or 'desc' for descending.
# @param generate_filter_options [Boolean] Whether to generate filter options in the response.
# @param api_key [String] Your API key for authentication.
# @param [Hash] opts the optional parameters
# @return [Array<(SearchResponse, Integer, Hash)>] SearchResponse data, response status code and response headers
def search_with_http_info(query, offset, limit, filters, sort, sort_order, generate_filter_options, api_key, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: DefaultApi.search ...'
end
# verify the required parameter 'query' is set
if @api_client.config.client_side_validation && query.nil?
fail ArgumentError, "Missing the required parameter 'query' when calling DefaultApi.search"
end
if @api_client.config.client_side_validation && query.to_s.length > 300
fail ArgumentError, 'invalid value for "query" when calling DefaultApi.search, the character length must be smaller than or equal to 300.'
end
pattern = Regexp.new(/.*/)
if @api_client.config.client_side_validation && query !~ pattern
fail ArgumentError, "invalid value for 'query' when calling DefaultApi.search, must conform to the pattern #{pattern}."
end
# verify the required parameter 'offset' is set
if @api_client.config.client_side_validation && offset.nil?
fail ArgumentError, "Missing the required parameter 'offset' when calling DefaultApi.search"
end
# verify the required parameter 'limit' is set
if @api_client.config.client_side_validation && limit.nil?
fail ArgumentError, "Missing the required parameter 'limit' when calling DefaultApi.search"
end
# verify the required parameter 'filters' is set
if @api_client.config.client_side_validation && filters.nil?
fail ArgumentError, "Missing the required parameter 'filters' when calling DefaultApi.search"
end
if @api_client.config.client_side_validation && filters.to_s.length > 3000
fail ArgumentError, 'invalid value for "filters" when calling DefaultApi.search, the character length must be smaller than or equal to 3000.'
end
pattern = Regexp.new(/.*/)
if @api_client.config.client_side_validation && filters !~ pattern
fail ArgumentError, "invalid value for 'filters' when calling DefaultApi.search, must conform to the pattern #{pattern}."
end
# verify the required parameter 'sort' is set
if @api_client.config.client_side_validation && sort.nil?
fail ArgumentError, "Missing the required parameter 'sort' when calling DefaultApi.search"
end
if @api_client.config.client_side_validation && sort.to_s.length > 300
fail ArgumentError, 'invalid value for "sort" when calling DefaultApi.search, the character length must be smaller than or equal to 300.'
end
pattern = Regexp.new(/.*/)
if @api_client.config.client_side_validation && sort !~ pattern
fail ArgumentError, "invalid value for 'sort' when calling DefaultApi.search, must conform to the pattern #{pattern}."
end
# verify the required parameter 'sort_order' is set
if @api_client.config.client_side_validation && sort_order.nil?
fail ArgumentError, "Missing the required parameter 'sort_order' when calling DefaultApi.search"
end
if @api_client.config.client_side_validation && sort_order.to_s.length > 4
fail ArgumentError, 'invalid value for "sort_order" when calling DefaultApi.search, the character length must be smaller than or equal to 4.'
end
pattern = Regexp.new(/(asc|desc)/)
if @api_client.config.client_side_validation && sort_order !~ pattern
fail ArgumentError, "invalid value for 'sort_order' when calling DefaultApi.search, must conform to the pattern #{pattern}."
end
# verify the required parameter 'generate_filter_options' is set
if @api_client.config.client_side_validation && generate_filter_options.nil?
fail ArgumentError, "Missing the required parameter 'generate_filter_options' when calling DefaultApi.search"
end
# verify the required parameter 'api_key' is set
if @api_client.config.client_side_validation && api_key.nil?
fail ArgumentError, "Missing the required parameter 'api_key' when calling DefaultApi.search"
end
if @api_client.config.client_side_validation && api_key.to_s.length > 300
fail ArgumentError, 'invalid value for "api_key" when calling DefaultApi.search, the character length must be smaller than or equal to 300.'
end
pattern = Regexp.new(/.*/)
if @api_client.config.client_side_validation && api_key !~ pattern
fail ArgumentError, "invalid value for 'api_key' when calling DefaultApi.search, must conform to the pattern #{pattern}."
end
# resource path
local_var_path = '/games'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'query'] = query
query_params[:'offset'] = offset
query_params[:'limit'] = limit
query_params[:'filters'] = filters
query_params[:'sort'] = sort
query_params[:'sort-order'] = sort_order
query_params[:'generate-filter-options'] = generate_filter_options
query_params[:'api-key'] = api_key
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'SearchResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['apiKey', 'headerApiKey']
new_options = opts.merge(
:operation => :"DefaultApi.search",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: DefaultApi#search\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get Similar Games
# Get games that are similar to the given one.
# @param id [Integer]
# @param limit [Integer]
# @param api_key [String]
# @param [Hash] opts the optional parameters
# @return [SimilarGamesResponse]
def similar(id, limit, api_key, opts = {})
data, _status_code, _headers = similar_with_http_info(id, limit, api_key, opts)
data
end
# Get Similar Games
# Get games that are similar to the given one.
# @param id [Integer]
# @param limit [Integer]
# @param api_key [String]
# @param [Hash] opts the optional parameters
# @return [Array<(SimilarGamesResponse, Integer, Hash)>] SimilarGamesResponse data, response status code and response headers
def similar_with_http_info(id, limit, api_key, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: DefaultApi.similar ...'
end
# verify the required parameter 'id' is set
if @api_client.config.client_side_validation && id.nil?
fail ArgumentError, "Missing the required parameter 'id' when calling DefaultApi.similar"
end
# verify the required parameter 'limit' is set
if @api_client.config.client_side_validation && limit.nil?
fail ArgumentError, "Missing the required parameter 'limit' when calling DefaultApi.similar"
end
# verify the required parameter 'api_key' is set
if @api_client.config.client_side_validation && api_key.nil?
fail ArgumentError, "Missing the required parameter 'api_key' when calling DefaultApi.similar"
end
if @api_client.config.client_side_validation && api_key.to_s.length > 300
fail ArgumentError, 'invalid value for "api_key" when calling DefaultApi.similar, the character length must be smaller than or equal to 300.'
end
pattern = Regexp.new(/.*/)
if @api_client.config.client_side_validation && api_key !~ pattern
fail ArgumentError, "invalid value for 'api_key' when calling DefaultApi.similar, must conform to the pattern #{pattern}."
end
# resource path
local_var_path = '/games/{id}/similar'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'limit'] = limit
query_params[:'api-key'] = api_key
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'SimilarGamesResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['apiKey', 'headerApiKey']
new_options = opts.merge(
:operation => :"DefaultApi.similar",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: DefaultApi#similar\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get Game Suggestions
# Get game suggestions based on (partial) search queries. For example, the query 'gt' will return games like GTA.
# @param query [String] The partial search query to get suggestions for.
# @param limit [Integer] The maximum number of suggestions to return.
# @param api_key [String] Your API key for authentication.
# @param [Hash] opts the optional parameters
# @return [SearchSuggestionResponse]
def suggest(query, limit, api_key, opts = {})
data, _status_code, _headers = suggest_with_http_info(query, limit, api_key, opts)
data
end
# Get Game Suggestions
# Get game suggestions based on (partial) search queries. For example, the query 'gt' will return games like GTA.
# @param query [String] The partial search query to get suggestions for.
# @param limit [Integer] The maximum number of suggestions to return.
# @param api_key [String] Your API key for authentication.
# @param [Hash] opts the optional parameters
# @return [Array<(SearchSuggestionResponse, Integer, Hash)>] SearchSuggestionResponse data, response status code and response headers
def suggest_with_http_info(query, limit, api_key, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: DefaultApi.suggest ...'
end
# verify the required parameter 'query' is set
if @api_client.config.client_side_validation && query.nil?
fail ArgumentError, "Missing the required parameter 'query' when calling DefaultApi.suggest"
end
if @api_client.config.client_side_validation && query.to_s.length > 300
fail ArgumentError, 'invalid value for "query" when calling DefaultApi.suggest, the character length must be smaller than or equal to 300.'
end
pattern = Regexp.new(/.*/)
if @api_client.config.client_side_validation && query !~ pattern
fail ArgumentError, "invalid value for 'query' when calling DefaultApi.suggest, must conform to the pattern #{pattern}."
end
# verify the required parameter 'limit' is set
if @api_client.config.client_side_validation && limit.nil?
fail ArgumentError, "Missing the required parameter 'limit' when calling DefaultApi.suggest"
end
# verify the required parameter 'api_key' is set
if @api_client.config.client_side_validation && api_key.nil?
fail ArgumentError, "Missing the required parameter 'api_key' when calling DefaultApi.suggest"
end
if @api_client.config.client_side_validation && api_key.to_s.length > 300
fail ArgumentError, 'invalid value for "api_key" when calling DefaultApi.suggest, the character length must be smaller than or equal to 300.'
end
pattern = Regexp.new(/.*/)
if @api_client.config.client_side_validation && api_key !~ pattern
fail ArgumentError, "invalid value for 'api_key' when calling DefaultApi.suggest, must conform to the pattern #{pattern}."
end
# resource path
local_var_path = '/games/suggestions'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'query'] = query
query_params[:'limit'] = limit
query_params[:'api-key'] = api_key
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'SearchSuggestionResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['apiKey', 'headerApiKey']
new_options = opts.merge(
:operation => :"DefaultApi.suggest",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: DefaultApi#suggest\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end