=begin comment
GameBrain API
GameBrain API
The version of the OpenAPI document: 1.0.1
Contact: mail@gamebrain.co
Generated by: https://openapi-generator.tech
=end comment
=cut
#
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
# Do not edit the class manually.
# Ref: https://openapi-generator.tech
#
package WWW::OpenAPIClient::DefaultApi;
require 5.6.0;
use strict;
use warnings;
use utf8;
use Exporter;
use Carp qw( croak );
use Log::Any qw($log);
use WWW::OpenAPIClient::ApiClient;
use base "Class::Data::Inheritable";
__PACKAGE__->mk_classdata('method_documentation' => {});
sub new {
my $class = shift;
my $api_client;
if ($_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
$api_client = $_[0];
} else {
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
}
bless { api_client => $api_client }, $class;
}
#
# detail
#
# Get Game Details
#
# @param int $id The unique identifier of the game. (required)
# @param string $api_key Your API key for authentication. (required)
{
my $params = {
'id' => {
data_type => 'int',
description => 'The unique identifier of the game.',
required => '1',
},
'api_key' => {
data_type => 'string',
description => 'Your API key for authentication.',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'detail' } = {
summary => 'Get Game Details',
params => $params,
returns => 'GameResponse',
};
}
# @return GameResponse
#
sub detail {
my ($self, %args) = @_;
# verify the required parameter 'id' is set
unless (exists $args{'id'}) {
croak("Missing the required parameter 'id' when calling detail");
}
# verify the required parameter 'api_key' is set
unless (exists $args{'api_key'}) {
croak("Missing the required parameter 'api_key' when calling detail");
}
# parse inputs
my $_resource_path = '/games/{id}';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# query params
if ( exists $args{'api_key'}) {
$query_params->{'api-key'} = $self->{api_client}->to_query_value($args{'api_key'});
}
# path params
if ( exists $args{'id'}) {
my $_base_variable = "{" . "id" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'id'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(apiKey headerApiKey )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('GameResponse', $response);
return $_response_object;
}
#
# news
#
# Get Game News
#
# @param int $id (required)
# @param int $offset (required)
# @param int $limit (required)
# @param string $api_key (required)
{
my $params = {
'id' => {
data_type => 'int',
description => '',
required => '1',
},
'offset' => {
data_type => 'int',
description => '',
required => '1',
},
'limit' => {
data_type => 'int',
description => '',
required => '1',
},
'api_key' => {
data_type => 'string',
description => '',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'news' } = {
summary => 'Get Game News',
params => $params,
returns => 'GameNewsResponse',
};
}
# @return GameNewsResponse
#
sub news {
my ($self, %args) = @_;
# verify the required parameter 'id' is set
unless (exists $args{'id'}) {
croak("Missing the required parameter 'id' when calling news");
}
# verify the required parameter 'offset' is set
unless (exists $args{'offset'}) {
croak("Missing the required parameter 'offset' when calling news");
}
# verify the required parameter 'limit' is set
unless (exists $args{'limit'}) {
croak("Missing the required parameter 'limit' when calling news");
}
# verify the required parameter 'api_key' is set
unless (exists $args{'api_key'}) {
croak("Missing the required parameter 'api_key' when calling news");
}
# parse inputs
my $_resource_path = '/games/{id}/news';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# query params
if ( exists $args{'offset'}) {
$query_params->{'offset'} = $self->{api_client}->to_query_value($args{'offset'});
}
# query params
if ( exists $args{'limit'}) {
$query_params->{'limit'} = $self->{api_client}->to_query_value($args{'limit'});
}
# query params
if ( exists $args{'api_key'}) {
$query_params->{'api-key'} = $self->{api_client}->to_query_value($args{'api_key'});
}
# path params
if ( exists $args{'id'}) {
my $_base_variable = "{" . "id" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'id'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(apiKey headerApiKey )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('GameNewsResponse', $response);
return $_response_object;
}
#
# search
#
# Search Games
#
# @param string $query The search query, e.g., game name, platform, genre, or any combination. (required)
# @param int $offset The number of results to skip before starting to collect the result set. Between 0 and 1000. (required)
# @param int $limit The maximum number of results to return between 1 and 10. (required)
# @param string $filters JSON array of filter objects to apply to the search. (required)
# @param string $sort The field by which to sort the results, either computed_rating, price, or release_date (required)
# @param string $sort_order The sort order: 'asc' for ascending or 'desc' for descending. (required)
# @param boolean $generate_filter_options Whether to generate filter options in the response. (required)
# @param string $api_key Your API key for authentication. (required)
{
my $params = {
'query' => {
data_type => 'string',
description => 'The search query, e.g., game name, platform, genre, or any combination.',
required => '1',
},
'offset' => {
data_type => 'int',
description => 'The number of results to skip before starting to collect the result set. Between 0 and 1000.',
required => '1',
},
'limit' => {
data_type => 'int',
description => 'The maximum number of results to return between 1 and 10.',
required => '1',
},
'filters' => {
data_type => 'string',
description => 'JSON array of filter objects to apply to the search.',
required => '1',
},
'sort' => {
data_type => 'string',
description => 'The field by which to sort the results, either computed_rating, price, or release_date',
required => '1',
},
'sort_order' => {
data_type => 'string',
description => 'The sort order: 'asc' for ascending or 'desc' for descending.',
required => '1',
},
'generate_filter_options' => {
data_type => 'boolean',
description => 'Whether to generate filter options in the response.',
required => '1',
},
'api_key' => {
data_type => 'string',
description => 'Your API key for authentication.',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'search' } = {
summary => 'Search Games',
params => $params,
returns => 'SearchResponse',
};
}
# @return SearchResponse
#
sub search {
my ($self, %args) = @_;
# verify the required parameter 'query' is set
unless (exists $args{'query'}) {
croak("Missing the required parameter 'query' when calling search");
}
# verify the required parameter 'offset' is set
unless (exists $args{'offset'}) {
croak("Missing the required parameter 'offset' when calling search");
}
# verify the required parameter 'limit' is set
unless (exists $args{'limit'}) {
croak("Missing the required parameter 'limit' when calling search");
}
# verify the required parameter 'filters' is set
unless (exists $args{'filters'}) {
croak("Missing the required parameter 'filters' when calling search");
}
# verify the required parameter 'sort' is set
unless (exists $args{'sort'}) {
croak("Missing the required parameter 'sort' when calling search");
}
# verify the required parameter 'sort_order' is set
unless (exists $args{'sort_order'}) {
croak("Missing the required parameter 'sort_order' when calling search");
}
# verify the required parameter 'generate_filter_options' is set
unless (exists $args{'generate_filter_options'}) {
croak("Missing the required parameter 'generate_filter_options' when calling search");
}
# verify the required parameter 'api_key' is set
unless (exists $args{'api_key'}) {
croak("Missing the required parameter 'api_key' when calling search");
}
# parse inputs
my $_resource_path = '/games';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# query params
if ( exists $args{'query'}) {
$query_params->{'query'} = $self->{api_client}->to_query_value($args{'query'});
}
# query params
if ( exists $args{'offset'}) {
$query_params->{'offset'} = $self->{api_client}->to_query_value($args{'offset'});
}
# query params
if ( exists $args{'limit'}) {
$query_params->{'limit'} = $self->{api_client}->to_query_value($args{'limit'});
}
# query params
if ( exists $args{'filters'}) {
$query_params->{'filters'} = $self->{api_client}->to_query_value($args{'filters'});
}
# query params
if ( exists $args{'sort'}) {
$query_params->{'sort'} = $self->{api_client}->to_query_value($args{'sort'});
}
# query params
if ( exists $args{'sort_order'}) {
$query_params->{'sort-order'} = $self->{api_client}->to_query_value($args{'sort_order'});
}
# query params
if ( exists $args{'generate_filter_options'}) {
$query_params->{'generate-filter-options'} = $self->{api_client}->to_query_value($args{'generate_filter_options'});
}
# query params
if ( exists $args{'api_key'}) {
$query_params->{'api-key'} = $self->{api_client}->to_query_value($args{'api_key'});
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(apiKey headerApiKey )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('SearchResponse', $response);
return $_response_object;
}
#
# similar
#
# Get Similar Games
#
# @param int $id (required)
# @param int $limit (required)
# @param string $api_key (required)
{
my $params = {
'id' => {
data_type => 'int',
description => '',
required => '1',
},
'limit' => {
data_type => 'int',
description => '',
required => '1',
},
'api_key' => {
data_type => 'string',
description => '',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'similar' } = {
summary => 'Get Similar Games',
params => $params,
returns => 'SimilarGamesResponse',
};
}
# @return SimilarGamesResponse
#
sub similar {
my ($self, %args) = @_;
# verify the required parameter 'id' is set
unless (exists $args{'id'}) {
croak("Missing the required parameter 'id' when calling similar");
}
# verify the required parameter 'limit' is set
unless (exists $args{'limit'}) {
croak("Missing the required parameter 'limit' when calling similar");
}
# verify the required parameter 'api_key' is set
unless (exists $args{'api_key'}) {
croak("Missing the required parameter 'api_key' when calling similar");
}
# parse inputs
my $_resource_path = '/games/{id}/similar';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# query params
if ( exists $args{'limit'}) {
$query_params->{'limit'} = $self->{api_client}->to_query_value($args{'limit'});
}
# query params
if ( exists $args{'api_key'}) {
$query_params->{'api-key'} = $self->{api_client}->to_query_value($args{'api_key'});
}
# path params
if ( exists $args{'id'}) {
my $_base_variable = "{" . "id" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'id'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(apiKey headerApiKey )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('SimilarGamesResponse', $response);
return $_response_object;
}
#
# suggest
#
# Get Game Suggestions
#
# @param string $query The partial search query to get suggestions for. (required)
# @param int $limit The maximum number of suggestions to return. (required)
# @param string $api_key Your API key for authentication. (required)
{
my $params = {
'query' => {
data_type => 'string',
description => 'The partial search query to get suggestions for.',
required => '1',
},
'limit' => {
data_type => 'int',
description => 'The maximum number of suggestions to return.',
required => '1',
},
'api_key' => {
data_type => 'string',
description => 'Your API key for authentication.',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'suggest' } = {
summary => 'Get Game Suggestions',
params => $params,
returns => 'SearchSuggestionResponse',
};
}
# @return SearchSuggestionResponse
#
sub suggest {
my ($self, %args) = @_;
# verify the required parameter 'query' is set
unless (exists $args{'query'}) {
croak("Missing the required parameter 'query' when calling suggest");
}
# verify the required parameter 'limit' is set
unless (exists $args{'limit'}) {
croak("Missing the required parameter 'limit' when calling suggest");
}
# verify the required parameter 'api_key' is set
unless (exists $args{'api_key'}) {
croak("Missing the required parameter 'api_key' when calling suggest");
}
# parse inputs
my $_resource_path = '/games/suggestions';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# query params
if ( exists $args{'query'}) {
$query_params->{'query'} = $self->{api_client}->to_query_value($args{'query'});
}
# query params
if ( exists $args{'limit'}) {
$query_params->{'limit'} = $self->{api_client}->to_query_value($args{'limit'});
}
# query params
if ( exists $args{'api_key'}) {
$query_params->{'api-key'} = $self->{api_client}->to_query_value($args{'api_key'});
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(apiKey headerApiKey )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('SearchSuggestionResponse', $response);
return $_response_object;
}
1;