# NOTE: This file is auto generated by OpenAPI Generator 7.8.0-SNAPSHOT (https://openapi-generator.tech).
# Do not edit this file manually.
defmodule GameBrainAPI.Api.Default do
@moduledoc """
API calls for all endpoints tagged `Default`.
"""
alias GameBrainAPI.Connection
import GameBrainAPI.RequestBuilder
@doc """
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.
### Parameters
- `connection` (GameBrainAPI.Connection): Connection to server
- `id` (integer()): The unique identifier of the game.
- `api_key` (String.t): Your API key for authentication.
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, GameBrainAPI.Model.GameResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec detail(Tesla.Env.client, integer(), String.t, keyword()) :: {:ok, GameBrainAPI.Model.GameResponse.t} | {:error, Tesla.Env.t}
def detail(connection, id, api_key, _opts \\ []) do
request =
%{}
|> method(:get)
|> url("/games/#{id}")
|> add_param(:query, :"api-key", api_key)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, GameBrainAPI.Model.GameResponse}
])
end
@doc """
Get Game News
Get news related to the given game.
### Parameters
- `connection` (GameBrainAPI.Connection): Connection to server
- `id` (integer()):
- `offset` (integer()):
- `limit` (integer()):
- `api_key` (String.t):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, GameBrainAPI.Model.GameNewsResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec news(Tesla.Env.client, integer(), integer(), integer(), String.t, keyword()) :: {:ok, GameBrainAPI.Model.GameNewsResponse.t} | {:error, Tesla.Env.t}
def news(connection, id, offset, limit, api_key, _opts \\ []) do
request =
%{}
|> method(:get)
|> url("/games/#{id}/news")
|> add_param(:query, :offset, offset)
|> add_param(:query, :limit, limit)
|> add_param(:query, :"api-key", api_key)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, GameBrainAPI.Model.GameNewsResponse}
])
end
@doc """
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
### Parameters
- `connection` (GameBrainAPI.Connection): Connection to server
- `query` (String.t): The search query, e.g., game name, platform, genre, or any combination.
- `offset` (integer()): The number of results to skip before starting to collect the result set. Between 0 and 1000.
- `limit` (integer()): The maximum number of results to return between 1 and 10.
- `filters` (String.t): JSON array of filter objects to apply to the search.
- `sort` (String.t): The field by which to sort the results, either computed_rating, price, or release_date
- `sort_order` (String.t): The sort order: 'asc' for ascending or 'desc' for descending.
- `generate_filter_options` (boolean()): Whether to generate filter options in the response.
- `api_key` (String.t): Your API key for authentication.
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, GameBrainAPI.Model.SearchResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec search(Tesla.Env.client, String.t, integer(), integer(), String.t, String.t, String.t, boolean(), String.t, keyword()) :: {:ok, GameBrainAPI.Model.SearchResponse.t} | {:error, Tesla.Env.t}
def search(connection, query, offset, limit, filters, sort, sort_order, generate_filter_options, api_key, _opts \\ []) do
request =
%{}
|> method(:get)
|> url("/games")
|> add_param(:query, :query, query)
|> add_param(:query, :offset, offset)
|> add_param(:query, :limit, limit)
|> add_param(:query, :filters, filters)
|> add_param(:query, :sort, sort)
|> add_param(:query, :"sort-order", sort_order)
|> add_param(:query, :"generate-filter-options", generate_filter_options)
|> add_param(:query, :"api-key", api_key)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, GameBrainAPI.Model.SearchResponse}
])
end
@doc """
Get Similar Games
Get games that are similar to the given one.
### Parameters
- `connection` (GameBrainAPI.Connection): Connection to server
- `id` (integer()):
- `limit` (integer()):
- `api_key` (String.t):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, GameBrainAPI.Model.SimilarGamesResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec similar(Tesla.Env.client, integer(), integer(), String.t, keyword()) :: {:ok, GameBrainAPI.Model.SimilarGamesResponse.t} | {:error, Tesla.Env.t}
def similar(connection, id, limit, api_key, _opts \\ []) do
request =
%{}
|> method(:get)
|> url("/games/#{id}/similar")
|> add_param(:query, :limit, limit)
|> add_param(:query, :"api-key", api_key)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, GameBrainAPI.Model.SimilarGamesResponse}
])
end
@doc """
Get Game Suggestions
Get game suggestions based on (partial) search queries. For example, the query 'gt' will return games like GTA.
### Parameters
- `connection` (GameBrainAPI.Connection): Connection to server
- `query` (String.t): The partial search query to get suggestions for.
- `limit` (integer()): The maximum number of suggestions to return.
- `api_key` (String.t): Your API key for authentication.
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, GameBrainAPI.Model.SearchSuggestionResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec suggest(Tesla.Env.client, String.t, integer(), String.t, keyword()) :: {:ok, GameBrainAPI.Model.SearchSuggestionResponse.t} | {:error, Tesla.Env.t}
def suggest(connection, query, limit, api_key, _opts \\ []) do
request =
%{}
|> method(:get)
|> url("/games/suggestions")
|> add_param(:query, :query, query)
|> add_param(:query, :limit, limit)
|> add_param(:query, :"api-key", api_key)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, GameBrainAPI.Model.SearchSuggestionResponse}
])
end
end