1267 lines
63 KiB
Rust
1267 lines
63 KiB
Rust
/*
|
|
* Gamenight
|
|
*
|
|
* Api specification for a Gamenight server
|
|
*
|
|
* The version of the OpenAPI document: 1.0
|
|
* Contact: dennis@brentj.es
|
|
* Generated by: https://openapi-generator.tech
|
|
*/
|
|
|
|
|
|
use async_trait::async_trait;
|
|
use reqwest;
|
|
use std::sync::Arc;
|
|
use serde::{Deserialize, Serialize, de::Error as _};
|
|
use crate::{apis::ResponseContent, models};
|
|
use super::{Error, configuration};
|
|
use crate::apis::ContentType;
|
|
|
|
#[async_trait]
|
|
pub trait DefaultApi: Send + Sync {
|
|
|
|
/// GET /authorized_location_user_ids
|
|
///
|
|
///
|
|
async fn authorized_location_user_ids_get<'location_id>(&self, location_id: Option<models::LocationId>) -> Result<Vec<models::UserId>, Error<AuthorizedLocationUserIdsGetError>>;
|
|
|
|
/// POST /disown
|
|
///
|
|
///
|
|
async fn disown_post<'game_id>(&self, game_id: Option<models::GameId>) -> Result<(), Error<DisownPostError>>;
|
|
|
|
/// DELETE /game
|
|
///
|
|
///
|
|
async fn game_delete<'game_id>(&self, game_id: Option<models::GameId>) -> Result<(), Error<GameDeleteError>>;
|
|
|
|
/// GET /game
|
|
///
|
|
///
|
|
async fn game_get<'game_id>(&self, game_id: Option<models::GameId>) -> Result<models::Game, Error<GameGetError>>;
|
|
|
|
/// POST /game
|
|
///
|
|
///
|
|
async fn game_post<'add_game_request_body>(&self, add_game_request_body: Option<models::AddGameRequestBody>) -> Result<models::GameId, Error<GamePostError>>;
|
|
|
|
/// GET /games
|
|
///
|
|
///
|
|
async fn games_get<>(&self, ) -> Result<Vec<models::Game>, Error<GamesGetError>>;
|
|
|
|
/// GET /gamenight
|
|
///
|
|
///
|
|
async fn get_gamenight<'get_gamenight_request_body>(&self, get_gamenight_request_body: Option<models::GetGamenightRequestBody>) -> Result<models::Gamenight, Error<GetGamenightError>>;
|
|
|
|
/// GET /gamenights
|
|
///
|
|
/// Retrieve the list of gamenights on this gamenight server. Requires authorization.
|
|
async fn get_gamenights<>(&self, ) -> Result<Vec<models::Gamenight>, Error<GetGamenightsError>>;
|
|
|
|
/// GET /token
|
|
///
|
|
/// Submit your credentials to get a JWT-token to use with the rest of the api.
|
|
async fn get_token<'login>(&self, login: Option<models::Login>) -> Result<models::Token, Error<GetTokenError>>;
|
|
|
|
/// POST /join
|
|
///
|
|
///
|
|
async fn join_post<'gamenight_id>(&self, gamenight_id: Option<models::GamenightId>) -> Result<(), Error<JoinPostError>>;
|
|
|
|
/// POST /leave
|
|
///
|
|
///
|
|
async fn leave_post<'gamenight_id>(&self, gamenight_id: Option<models::GamenightId>) -> Result<(), Error<LeavePostError>>;
|
|
|
|
/// POST /location_authorize
|
|
///
|
|
///
|
|
async fn location_authorize_post<'authorize_location_request_body>(&self, authorize_location_request_body: Option<models::AuthorizeLocationRequestBody>) -> Result<(), Error<LocationAuthorizePostError>>;
|
|
|
|
/// GET /location
|
|
///
|
|
///
|
|
async fn location_get<'location_id>(&self, location_id: Option<models::LocationId>) -> Result<models::Location, Error<LocationGetError>>;
|
|
|
|
/// POST /location
|
|
///
|
|
///
|
|
async fn location_post<'add_location_request_body>(&self, add_location_request_body: Option<models::AddLocationRequestBody>) -> Result<models::LocationId, Error<LocationPostError>>;
|
|
|
|
/// GET /locations
|
|
///
|
|
///
|
|
async fn locations_get<>(&self, ) -> Result<Vec<models::Location>, Error<LocationsGetError>>;
|
|
|
|
/// POST /own
|
|
///
|
|
///
|
|
async fn own_post<'own_game_request_body>(&self, own_game_request_body: Option<models::OwnGameRequestBody>) -> Result<(), Error<OwnPostError>>;
|
|
|
|
/// GET /owned_games
|
|
///
|
|
///
|
|
async fn owned_games_get<'user_id>(&self, user_id: Option<models::UserId>) -> Result<Vec<models::OwnedGame>, Error<OwnedGamesGetError>>;
|
|
|
|
/// GET /participants
|
|
///
|
|
/// Retrieve the participants of a single gamenight by id.
|
|
async fn participants_get<'gamenight_id>(&self, gamenight_id: Option<models::GamenightId>) -> Result<models::Participants, Error<ParticipantsGetError>>;
|
|
|
|
/// POST /gamenight
|
|
///
|
|
/// Add a gamenight by providing a name and a date, only available when providing an JWT token.
|
|
async fn post_gamenight<'add_gamenight_request_body>(&self, add_gamenight_request_body: Option<models::AddGamenightRequestBody>) -> Result<(), Error<PostGamenightError>>;
|
|
|
|
/// POST /user
|
|
///
|
|
/// Create a new user given a registration token and user information, username and email must be unique, and password and password_repeat must match.
|
|
async fn post_register<'registration>(&self, registration: Option<models::Registration>) -> Result<(), Error<PostRegisterError>>;
|
|
|
|
/// POST /token
|
|
///
|
|
/// Refresh your JWT-token without logging in again.
|
|
async fn post_token<>(&self, ) -> Result<models::Token, Error<PostTokenError>>;
|
|
|
|
/// POST /rename_game
|
|
///
|
|
///
|
|
async fn rename_game_post<'rename_game_request_body>(&self, rename_game_request_body: Option<models::RenameGameRequestBody>) -> Result<(), Error<RenameGamePostError>>;
|
|
|
|
/// GET /user
|
|
///
|
|
/// Get a user from primary id
|
|
async fn user_get<'user_id>(&self, user_id: Option<models::UserId>) -> Result<models::User, Error<UserGetError>>;
|
|
|
|
/// GET /users
|
|
///
|
|
///
|
|
async fn users_get<>(&self, ) -> Result<Vec<models::User>, Error<UsersGetError>>;
|
|
}
|
|
|
|
pub struct DefaultApiClient {
|
|
configuration: Arc<configuration::Configuration>
|
|
}
|
|
|
|
impl DefaultApiClient {
|
|
pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
|
|
Self { configuration }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#[async_trait]
|
|
impl DefaultApi for DefaultApiClient {
|
|
async fn authorized_location_user_ids_get<'location_id>(&self, location_id: Option<models::LocationId>) -> Result<Vec<models::UserId>, Error<AuthorizedLocationUserIdsGetError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/authorized_location_user_ids", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
local_var_req_builder = local_var_req_builder.json(&location_id);
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content_type = local_var_resp
|
|
.headers()
|
|
.get("content-type")
|
|
.and_then(|v| v.to_str().ok())
|
|
.unwrap_or("application/octet-stream");
|
|
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
match local_var_content_type {
|
|
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
|
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::UserId>`"))),
|
|
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::UserId>`")))),
|
|
}
|
|
} else {
|
|
let local_var_entity: Option<AuthorizedLocationUserIdsGetError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
async fn disown_post<'game_id>(&self, game_id: Option<models::GameId>) -> Result<(), Error<DisownPostError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/disown", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
local_var_req_builder = local_var_req_builder.json(&game_id);
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
Ok(())
|
|
} else {
|
|
let local_var_entity: Option<DisownPostError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
async fn game_delete<'game_id>(&self, game_id: Option<models::GameId>) -> Result<(), Error<GameDeleteError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/game", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
local_var_req_builder = local_var_req_builder.json(&game_id);
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
Ok(())
|
|
} else {
|
|
let local_var_entity: Option<GameDeleteError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
async fn game_get<'game_id>(&self, game_id: Option<models::GameId>) -> Result<models::Game, Error<GameGetError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/game", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
local_var_req_builder = local_var_req_builder.json(&game_id);
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content_type = local_var_resp
|
|
.headers()
|
|
.get("content-type")
|
|
.and_then(|v| v.to_str().ok())
|
|
.unwrap_or("application/octet-stream");
|
|
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
match local_var_content_type {
|
|
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
|
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Game`"))),
|
|
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::Game`")))),
|
|
}
|
|
} else {
|
|
let local_var_entity: Option<GameGetError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
async fn game_post<'add_game_request_body>(&self, add_game_request_body: Option<models::AddGameRequestBody>) -> Result<models::GameId, Error<GamePostError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/game", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
local_var_req_builder = local_var_req_builder.json(&add_game_request_body);
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content_type = local_var_resp
|
|
.headers()
|
|
.get("content-type")
|
|
.and_then(|v| v.to_str().ok())
|
|
.unwrap_or("application/octet-stream");
|
|
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
match local_var_content_type {
|
|
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
|
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GameId`"))),
|
|
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::GameId`")))),
|
|
}
|
|
} else {
|
|
let local_var_entity: Option<GamePostError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
async fn games_get<>(&self, ) -> Result<Vec<models::Game>, Error<GamesGetError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/games", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content_type = local_var_resp
|
|
.headers()
|
|
.get("content-type")
|
|
.and_then(|v| v.to_str().ok())
|
|
.unwrap_or("application/octet-stream");
|
|
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
match local_var_content_type {
|
|
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
|
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Game>`"))),
|
|
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::Game>`")))),
|
|
}
|
|
} else {
|
|
let local_var_entity: Option<GamesGetError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
async fn get_gamenight<'get_gamenight_request_body>(&self, get_gamenight_request_body: Option<models::GetGamenightRequestBody>) -> Result<models::Gamenight, Error<GetGamenightError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/gamenight", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
local_var_req_builder = local_var_req_builder.json(&get_gamenight_request_body);
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content_type = local_var_resp
|
|
.headers()
|
|
.get("content-type")
|
|
.and_then(|v| v.to_str().ok())
|
|
.unwrap_or("application/octet-stream");
|
|
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
match local_var_content_type {
|
|
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
|
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Gamenight`"))),
|
|
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::Gamenight`")))),
|
|
}
|
|
} else {
|
|
let local_var_entity: Option<GetGamenightError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
/// Retrieve the list of gamenights on this gamenight server. Requires authorization.
|
|
async fn get_gamenights<>(&self, ) -> Result<Vec<models::Gamenight>, Error<GetGamenightsError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/gamenights", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content_type = local_var_resp
|
|
.headers()
|
|
.get("content-type")
|
|
.and_then(|v| v.to_str().ok())
|
|
.unwrap_or("application/octet-stream");
|
|
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
match local_var_content_type {
|
|
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
|
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Gamenight>`"))),
|
|
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::Gamenight>`")))),
|
|
}
|
|
} else {
|
|
let local_var_entity: Option<GetGamenightsError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
/// Submit your credentials to get a JWT-token to use with the rest of the api.
|
|
async fn get_token<'login>(&self, login: Option<models::Login>) -> Result<models::Token, Error<GetTokenError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/token", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
local_var_req_builder = local_var_req_builder.json(&login);
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content_type = local_var_resp
|
|
.headers()
|
|
.get("content-type")
|
|
.and_then(|v| v.to_str().ok())
|
|
.unwrap_or("application/octet-stream");
|
|
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
match local_var_content_type {
|
|
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
|
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Token`"))),
|
|
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::Token`")))),
|
|
}
|
|
} else {
|
|
let local_var_entity: Option<GetTokenError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
async fn join_post<'gamenight_id>(&self, gamenight_id: Option<models::GamenightId>) -> Result<(), Error<JoinPostError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/join", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
local_var_req_builder = local_var_req_builder.json(&gamenight_id);
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
Ok(())
|
|
} else {
|
|
let local_var_entity: Option<JoinPostError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
async fn leave_post<'gamenight_id>(&self, gamenight_id: Option<models::GamenightId>) -> Result<(), Error<LeavePostError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/leave", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
local_var_req_builder = local_var_req_builder.json(&gamenight_id);
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
Ok(())
|
|
} else {
|
|
let local_var_entity: Option<LeavePostError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
async fn location_authorize_post<'authorize_location_request_body>(&self, authorize_location_request_body: Option<models::AuthorizeLocationRequestBody>) -> Result<(), Error<LocationAuthorizePostError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/location_authorize", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
local_var_req_builder = local_var_req_builder.json(&authorize_location_request_body);
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
Ok(())
|
|
} else {
|
|
let local_var_entity: Option<LocationAuthorizePostError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
async fn location_get<'location_id>(&self, location_id: Option<models::LocationId>) -> Result<models::Location, Error<LocationGetError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/location", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
local_var_req_builder = local_var_req_builder.json(&location_id);
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content_type = local_var_resp
|
|
.headers()
|
|
.get("content-type")
|
|
.and_then(|v| v.to_str().ok())
|
|
.unwrap_or("application/octet-stream");
|
|
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
match local_var_content_type {
|
|
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
|
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Location`"))),
|
|
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::Location`")))),
|
|
}
|
|
} else {
|
|
let local_var_entity: Option<LocationGetError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
async fn location_post<'add_location_request_body>(&self, add_location_request_body: Option<models::AddLocationRequestBody>) -> Result<models::LocationId, Error<LocationPostError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/location", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
local_var_req_builder = local_var_req_builder.json(&add_location_request_body);
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content_type = local_var_resp
|
|
.headers()
|
|
.get("content-type")
|
|
.and_then(|v| v.to_str().ok())
|
|
.unwrap_or("application/octet-stream");
|
|
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
match local_var_content_type {
|
|
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
|
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LocationId`"))),
|
|
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::LocationId`")))),
|
|
}
|
|
} else {
|
|
let local_var_entity: Option<LocationPostError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
async fn locations_get<>(&self, ) -> Result<Vec<models::Location>, Error<LocationsGetError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/locations", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content_type = local_var_resp
|
|
.headers()
|
|
.get("content-type")
|
|
.and_then(|v| v.to_str().ok())
|
|
.unwrap_or("application/octet-stream");
|
|
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
match local_var_content_type {
|
|
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
|
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Location>`"))),
|
|
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::Location>`")))),
|
|
}
|
|
} else {
|
|
let local_var_entity: Option<LocationsGetError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
async fn own_post<'own_game_request_body>(&self, own_game_request_body: Option<models::OwnGameRequestBody>) -> Result<(), Error<OwnPostError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/own", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
local_var_req_builder = local_var_req_builder.json(&own_game_request_body);
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
Ok(())
|
|
} else {
|
|
let local_var_entity: Option<OwnPostError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
async fn owned_games_get<'user_id>(&self, user_id: Option<models::UserId>) -> Result<Vec<models::OwnedGame>, Error<OwnedGamesGetError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/owned_games", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
local_var_req_builder = local_var_req_builder.json(&user_id);
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content_type = local_var_resp
|
|
.headers()
|
|
.get("content-type")
|
|
.and_then(|v| v.to_str().ok())
|
|
.unwrap_or("application/octet-stream");
|
|
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
match local_var_content_type {
|
|
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
|
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::OwnedGame>`"))),
|
|
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::OwnedGame>`")))),
|
|
}
|
|
} else {
|
|
let local_var_entity: Option<OwnedGamesGetError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
/// Retrieve the participants of a single gamenight by id.
|
|
async fn participants_get<'gamenight_id>(&self, gamenight_id: Option<models::GamenightId>) -> Result<models::Participants, Error<ParticipantsGetError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/participants", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
local_var_req_builder = local_var_req_builder.json(&gamenight_id);
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content_type = local_var_resp
|
|
.headers()
|
|
.get("content-type")
|
|
.and_then(|v| v.to_str().ok())
|
|
.unwrap_or("application/octet-stream");
|
|
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
match local_var_content_type {
|
|
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
|
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Participants`"))),
|
|
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::Participants`")))),
|
|
}
|
|
} else {
|
|
let local_var_entity: Option<ParticipantsGetError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
/// Add a gamenight by providing a name and a date, only available when providing an JWT token.
|
|
async fn post_gamenight<'add_gamenight_request_body>(&self, add_gamenight_request_body: Option<models::AddGamenightRequestBody>) -> Result<(), Error<PostGamenightError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/gamenight", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
local_var_req_builder = local_var_req_builder.json(&add_gamenight_request_body);
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
Ok(())
|
|
} else {
|
|
let local_var_entity: Option<PostGamenightError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
/// Create a new user given a registration token and user information, username and email must be unique, and password and password_repeat must match.
|
|
async fn post_register<'registration>(&self, registration: Option<models::Registration>) -> Result<(), Error<PostRegisterError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/user", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
local_var_req_builder = local_var_req_builder.json(®istration);
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
Ok(())
|
|
} else {
|
|
let local_var_entity: Option<PostRegisterError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
/// Refresh your JWT-token without logging in again.
|
|
async fn post_token<>(&self, ) -> Result<models::Token, Error<PostTokenError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/token", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content_type = local_var_resp
|
|
.headers()
|
|
.get("content-type")
|
|
.and_then(|v| v.to_str().ok())
|
|
.unwrap_or("application/octet-stream");
|
|
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
match local_var_content_type {
|
|
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
|
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Token`"))),
|
|
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::Token`")))),
|
|
}
|
|
} else {
|
|
let local_var_entity: Option<PostTokenError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
async fn rename_game_post<'rename_game_request_body>(&self, rename_game_request_body: Option<models::RenameGameRequestBody>) -> Result<(), Error<RenameGamePostError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/rename_game", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
local_var_req_builder = local_var_req_builder.json(&rename_game_request_body);
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
Ok(())
|
|
} else {
|
|
let local_var_entity: Option<RenameGamePostError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
/// Get a user from primary id
|
|
async fn user_get<'user_id>(&self, user_id: Option<models::UserId>) -> Result<models::User, Error<UserGetError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/user", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
local_var_req_builder = local_var_req_builder.json(&user_id);
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content_type = local_var_resp
|
|
.headers()
|
|
.get("content-type")
|
|
.and_then(|v| v.to_str().ok())
|
|
.unwrap_or("application/octet-stream");
|
|
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
match local_var_content_type {
|
|
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
|
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::User`"))),
|
|
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::User`")))),
|
|
}
|
|
} else {
|
|
let local_var_entity: Option<UserGetError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
async fn users_get<>(&self, ) -> Result<Vec<models::User>, Error<UsersGetError>> {
|
|
let local_var_configuration = &self.configuration;
|
|
|
|
let local_var_client = &local_var_configuration.client;
|
|
|
|
let local_var_uri_str = format!("{}/users", local_var_configuration.base_path);
|
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
|
|
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
|
}
|
|
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
|
|
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
|
};
|
|
|
|
let local_var_req = local_var_req_builder.build()?;
|
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
|
|
|
let local_var_status = local_var_resp.status();
|
|
let local_var_content_type = local_var_resp
|
|
.headers()
|
|
.get("content-type")
|
|
.and_then(|v| v.to_str().ok())
|
|
.unwrap_or("application/octet-stream");
|
|
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
|
let local_var_content = local_var_resp.text().await?;
|
|
|
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
|
match local_var_content_type {
|
|
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
|
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::User>`"))),
|
|
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::User>`")))),
|
|
}
|
|
} else {
|
|
let local_var_entity: Option<UsersGetError> = serde_json::from_str(&local_var_content).ok();
|
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
|
Err(Error::ResponseError(local_var_error))
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::authorized_location_user_ids_get`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum AuthorizedLocationUserIdsGetError {
|
|
Status401(models::Failure),
|
|
Status422(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::disown_post`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum DisownPostError {
|
|
Status401(models::Failure),
|
|
Status422(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::game_delete`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum GameDeleteError {
|
|
Status401(models::Failure),
|
|
Status422(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::game_get`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum GameGetError {
|
|
Status401(models::Failure),
|
|
Status422(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::game_post`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum GamePostError {
|
|
Status401(models::Failure),
|
|
Status422(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::games_get`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum GamesGetError {
|
|
Status401(models::Failure),
|
|
Status422(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::get_gamenight`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum GetGamenightError {
|
|
Status401(models::Failure),
|
|
Status422(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::get_gamenights`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum GetGamenightsError {
|
|
Status400(models::Failure),
|
|
Status401(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::get_token`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum GetTokenError {
|
|
Status401(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::join_post`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum JoinPostError {
|
|
Status401(models::Failure),
|
|
Status422(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::leave_post`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum LeavePostError {
|
|
Status401(models::Failure),
|
|
Status422(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::location_authorize_post`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum LocationAuthorizePostError {
|
|
Status401(models::Failure),
|
|
Status422(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::location_get`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum LocationGetError {
|
|
Status401(models::Failure),
|
|
Status422(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::location_post`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum LocationPostError {
|
|
Status401(models::Failure),
|
|
Status422(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::locations_get`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum LocationsGetError {
|
|
Status401(models::Failure),
|
|
Status422(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::own_post`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum OwnPostError {
|
|
Status401(models::Failure),
|
|
Status422(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::owned_games_get`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum OwnedGamesGetError {
|
|
Status401(models::Failure),
|
|
Status422(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::participants_get`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum ParticipantsGetError {
|
|
Status400(models::Failure),
|
|
Status401(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::post_gamenight`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum PostGamenightError {
|
|
Status401(models::Failure),
|
|
Status422(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::post_register`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum PostRegisterError {
|
|
Status422(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::post_token`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum PostTokenError {
|
|
Status401(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::rename_game_post`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum RenameGamePostError {
|
|
Status401(models::Failure),
|
|
Status422(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::user_get`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum UserGetError {
|
|
Status401(models::Failure),
|
|
Status404(models::Failure),
|
|
Status422(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`DefaultApi::users_get`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum UsersGetError {
|
|
Status400(models::Failure),
|
|
Status401(models::Failure),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|