forked from Roflin/gamenight
Adds own/disown game logic
This commit is contained in:
@@ -27,6 +27,7 @@ All URIs are relative to *http://localhost:8080*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*DefaultApi* | [**disown_post**](docs/DefaultApi.md#disown_post) | **POST** /disown |
|
||||
*DefaultApi* | [**game_get**](docs/DefaultApi.md#game_get) | **GET** /game |
|
||||
*DefaultApi* | [**game_post**](docs/DefaultApi.md#game_post) | **POST** /game |
|
||||
*DefaultApi* | [**games_get**](docs/DefaultApi.md#games_get) | **GET** /games |
|
||||
@@ -35,6 +36,8 @@ Class | Method | HTTP request | Description
|
||||
*DefaultApi* | [**get_token**](docs/DefaultApi.md#get_token) | **GET** /token |
|
||||
*DefaultApi* | [**join_post**](docs/DefaultApi.md#join_post) | **POST** /join |
|
||||
*DefaultApi* | [**leave_post**](docs/DefaultApi.md#leave_post) | **POST** /leave |
|
||||
*DefaultApi* | [**own_post**](docs/DefaultApi.md#own_post) | **POST** /own |
|
||||
*DefaultApi* | [**owned_games_get**](docs/DefaultApi.md#owned_games_get) | **GET** /owned_games |
|
||||
*DefaultApi* | [**participants_get**](docs/DefaultApi.md#participants_get) | **GET** /participants | Get all participants for a gamenight
|
||||
*DefaultApi* | [**post_gamenight**](docs/DefaultApi.md#post_gamenight) | **POST** /gamenight |
|
||||
*DefaultApi* | [**post_register**](docs/DefaultApi.md#post_register) | **POST** /user |
|
||||
|
||||
@@ -4,6 +4,7 @@ All URIs are relative to *http://localhost:8080*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**disown_post**](DefaultApi.md#disown_post) | **POST** /disown |
|
||||
[**game_get**](DefaultApi.md#game_get) | **GET** /game |
|
||||
[**game_post**](DefaultApi.md#game_post) | **POST** /game |
|
||||
[**games_get**](DefaultApi.md#games_get) | **GET** /games |
|
||||
@@ -12,6 +13,8 @@ Method | HTTP request | Description
|
||||
[**get_token**](DefaultApi.md#get_token) | **GET** /token |
|
||||
[**join_post**](DefaultApi.md#join_post) | **POST** /join |
|
||||
[**leave_post**](DefaultApi.md#leave_post) | **POST** /leave |
|
||||
[**own_post**](DefaultApi.md#own_post) | **POST** /own |
|
||||
[**owned_games_get**](DefaultApi.md#owned_games_get) | **GET** /owned_games |
|
||||
[**participants_get**](DefaultApi.md#participants_get) | **GET** /participants | Get all participants for a gamenight
|
||||
[**post_gamenight**](DefaultApi.md#post_gamenight) | **POST** /gamenight |
|
||||
[**post_register**](DefaultApi.md#post_register) | **POST** /user |
|
||||
@@ -21,6 +24,34 @@ Method | HTTP request | Description
|
||||
|
||||
|
||||
|
||||
## disown_post
|
||||
|
||||
> disown_post(game_id)
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**game_id** | Option<[**GameId**](GameId.md)> | | |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[JWT-Auth](../README.md#JWT-Auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
## game_get
|
||||
|
||||
> models::Game game_get(game_id)
|
||||
@@ -243,6 +274,59 @@ Name | Type | Description | Required | Notes
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
## own_post
|
||||
|
||||
> own_post(game_id)
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**game_id** | Option<[**GameId**](GameId.md)> | | |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[JWT-Auth](../README.md#JWT-Auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
## owned_games_get
|
||||
|
||||
> Vec<String> owned_games_get()
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
**Vec<String>**
|
||||
|
||||
### Authorization
|
||||
|
||||
[JWT-Auth](../README.md#JWT-Auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
## participants_get
|
||||
|
||||
> models::Participants participants_get(gamenight_id)
|
||||
|
||||
@@ -15,6 +15,15 @@ use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`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 [`game_get`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
@@ -86,6 +95,24 @@ pub enum LeavePostError {
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method [`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 [`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 [`participants_get`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
@@ -140,6 +167,35 @@ pub enum UserGetError {
|
||||
}
|
||||
|
||||
|
||||
pub async fn disown_post(configuration: &configuration::Configuration, game_id: Option<models::GameId>) -> Result<(), Error<DisownPostError>> {
|
||||
// add a prefix to parameters to efficiently prevent name collisions
|
||||
let p_game_id = game_id;
|
||||
|
||||
let uri_str = format!("{}/disown", configuration.base_path);
|
||||
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
if let Some(ref token) = configuration.bearer_access_token {
|
||||
req_builder = req_builder.bearer_auth(token.to_owned());
|
||||
};
|
||||
req_builder = req_builder.json(&p_game_id);
|
||||
|
||||
let req = req_builder.build()?;
|
||||
let resp = configuration.client.execute(req).await?;
|
||||
|
||||
let status = resp.status();
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
Ok(())
|
||||
} else {
|
||||
let content = resp.text().await?;
|
||||
let entity: Option<DisownPostError> = serde_json::from_str(&content).ok();
|
||||
Err(Error::ResponseError(ResponseContent { status, content, entity }))
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn game_get(configuration: &configuration::Configuration, game_id: Option<models::GameId>) -> Result<models::Game, Error<GameGetError>> {
|
||||
// add a prefix to parameters to efficiently prevent name collisions
|
||||
let p_game_id = game_id;
|
||||
@@ -420,6 +476,72 @@ pub async fn leave_post(configuration: &configuration::Configuration, gamenight_
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn own_post(configuration: &configuration::Configuration, game_id: Option<models::GameId>) -> Result<(), Error<OwnPostError>> {
|
||||
// add a prefix to parameters to efficiently prevent name collisions
|
||||
let p_game_id = game_id;
|
||||
|
||||
let uri_str = format!("{}/own", configuration.base_path);
|
||||
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
if let Some(ref token) = configuration.bearer_access_token {
|
||||
req_builder = req_builder.bearer_auth(token.to_owned());
|
||||
};
|
||||
req_builder = req_builder.json(&p_game_id);
|
||||
|
||||
let req = req_builder.build()?;
|
||||
let resp = configuration.client.execute(req).await?;
|
||||
|
||||
let status = resp.status();
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
Ok(())
|
||||
} else {
|
||||
let content = resp.text().await?;
|
||||
let entity: Option<OwnPostError> = serde_json::from_str(&content).ok();
|
||||
Err(Error::ResponseError(ResponseContent { status, content, entity }))
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn owned_games_get(configuration: &configuration::Configuration, ) -> Result<Vec<String>, Error<OwnedGamesGetError>> {
|
||||
|
||||
let uri_str = format!("{}/owned_games", configuration.base_path);
|
||||
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
if let Some(ref token) = configuration.bearer_access_token {
|
||||
req_builder = req_builder.bearer_auth(token.to_owned());
|
||||
};
|
||||
|
||||
let req = req_builder.build()?;
|
||||
let resp = configuration.client.execute(req).await?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text().await?;
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&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<String>`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<String>`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text().await?;
|
||||
let entity: Option<OwnedGamesGetError> = serde_json::from_str(&content).ok();
|
||||
Err(Error::ResponseError(ResponseContent { status, content, entity }))
|
||||
}
|
||||
}
|
||||
|
||||
/// Retrieve the participants of a single gamenight by id.
|
||||
pub async fn participants_get(configuration: &configuration::Configuration, gamenight_id: Option<models::GamenightId>) -> Result<models::Participants, Error<ParticipantsGetError>> {
|
||||
// add a prefix to parameters to efficiently prevent name collisions
|
||||
|
||||
Reference in New Issue
Block a user