From 7e9cdb8b91198fe72516755b2755b0d9bca949af Mon Sep 17 00:00:00 2001 From: C0D3 M4513R <28912031+C0D3-M4513R@users.noreply.github.com> Date: Wed, 3 Dec 2025 15:49:28 +0100 Subject: [PATCH 1/6] Update Openapi-Generator Fixes: #28 --- .github/workflows/ci.yaml | 2 +- .openapi-generator/VERSION | 2 +- generate.sh | 10 +++------- openapitools.json | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f521ac8..903712e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,7 +25,7 @@ jobs: - name: Install OpenAPI Generator CLI run: npm install @openapitools/openapi-generator-cli - name: Set OpenAPI Generator version - run: ./node_modules/\@openapitools/openapi-generator-cli/main.js version-manager set 7.7.0 + run: ./node_modules/\@openapitools/openapi-generator-cli/main.js version-manager set 7.17.0 - name: Set up JDK 20 uses: actions/setup-java@v4 with: diff --git a/.openapi-generator/VERSION b/.openapi-generator/VERSION index 1985849..6328c54 100644 --- a/.openapi-generator/VERSION +++ b/.openapi-generator/VERSION @@ -1 +1 @@ -7.7.0 +7.17.0 diff --git a/generate.sh b/generate.sh index 0feac70..8799fca 100755 --- a/generate.sh +++ b/generate.sh @@ -25,15 +25,11 @@ find src -type f -exec sed -i '/^\s*\/\/\/\s*$/d' {} \; # Cookie storage sed -i 's/Client::new()/Client::builder().cookie_store(true).build().unwrap()/g' src/apis/configuration.rs -sed -i 's/, features = \["json", "multipart"\]/, default-features = false, features = \["json", "cookies", "multipart"\]/g' Cargo.toml +sed -i 's/, features = \["json", "multipart"\]/, features = \["json", "cookies", "multipart"\]/g' Cargo.toml #Fix example printf "\n[dev-dependencies]\ntokio = { version = '1', features = ['macros', 'rt-multi-thread'] }" >> Cargo.toml -#Add feature section to Cargo.toml -printf "\n[features]\ndefault = [\"reqwest/default\"]" >> Cargo.toml - - # https://github.com/vrchatapi/specification/issues/241 cat patches/2FA_Current_User.rs >> src/models/current_user.rs sed -i 's/pub use self::current_user::CurrentUser;/pub use self::current_user::{EitherUserOrTwoFactor, CurrentUser};/g' src/models/mod.rs @@ -43,11 +39,11 @@ sed -i 's/Result>/Result>,\n\tfilename: impl Into<::std::borrow::Cow<'\''static, str>>,\n\tmime_type: &str,\2\3let part = reqwest::multipart::Part::bytes(file).file_name(filename).mime_str(mime_type)?;\n\tlocal_var_form = local_var_form.part("file", part);|g' src/apis/files_api.rs +perl -0pi -e 's|(fn\s+[^(]*\([^)]*)file:\s+:?:?std::path::PathBuf,?([^)]*)((?:(?!\/\/ TODO: support file upload for '\''file'\'' parameter)[\s\S])*)\/\/ TODO: support file upload for '\''file'\'' parameter|\1file: impl Into<::std::borrow::Cow<'\''static, [u8]>>,\n\tfilename: impl Into<::std::borrow::Cow<'\''static, str>>,\n\tmime_type: &str,\2\3let part = reqwest::multipart::Part::bytes(p_form_file).file_name(filename).mime_str(mime_type)?;\n\tmultipart_form = multipart_form.part("file", part);|g' src/apis/files_api.rs find src/ -type f -name "*.rs" -exec sed -i 's/models::models/models/g' {} + -find src/ -type f -name "*.rs" -exec sed -i 's/local_var_form\.text("data", data\.to_string())/local_var_form.text("data", serde_json::to_string_pretty(\&data)?)/g' {} + +find src/ -type f -name "*.rs" -exec sed -i 's/multipart_form\.text("data", p_form_data\.to_string())/multipart_form.text("data", serde_json::to_string_pretty(\&p_form_data)?)/g' {} + cargo fmt cargo build diff --git a/openapitools.json b/openapitools.json index ec75728..354feb9 100644 --- a/openapitools.json +++ b/openapitools.json @@ -2,6 +2,6 @@ "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", "spaces": 2, "generator-cli": { - "version": "7.7.0" + "version": "7.17.0" } } From 4b43048ae541ccbd390c7ac7142422540b02dc7f Mon Sep 17 00:00:00 2001 From: C0D3 M4513R <28912031+C0D3-M4513R@users.noreply.github.com> Date: Wed, 3 Dec 2025 15:50:54 +0100 Subject: [PATCH 2/6] Regenerate --- Cargo.toml | 11 +- docs/GroupSearchSort.md | 4 +- src/apis/authentication_api.rs | 1157 ++++++------ src/apis/avatars_api.rs | 1028 ++++++----- src/apis/calendar_api.rs | 778 ++++---- src/apis/configuration.rs | 1 - src/apis/economy_api.rs | 1150 ++++++------ src/apis/favorites_api.rs | 527 +++--- src/apis/files_api.rs | 1140 +++++++----- src/apis/friends_api.rs | 320 ++-- src/apis/groups_api.rs | 2979 ++++++++++++++++-------------- src/apis/instances_api.rs | 395 ++-- src/apis/inventory_api.rs | 559 +++--- src/apis/invite_api.rs | 754 ++++---- src/apis/jams_api.rs | 183 +- src/apis/miscellaneous_api.rs | 540 +++--- src/apis/mod.rs | 21 + src/apis/notifications_api.rs | 399 ++-- src/apis/playermoderation_api.rs | 268 +-- src/apis/prints_api.rs | 328 ++-- src/apis/props_api.rs | 59 +- src/apis/users_api.rs | 1097 ++++++----- src/apis/worlds_api.rs | 1149 ++++++------ src/lib.rs | 1 + src/models/group_search_sort.rs | 10 +- 25 files changed, 8056 insertions(+), 6802 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d6a545f..cf236ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,11 +10,14 @@ edition = "2021" serde = { version = "^1.0", features = ["derive"] } serde_with = { version = "^3.8", default-features = false, features = ["base64", "std", "macros"] } serde_json = "^1.0" +serde_repr = "^0.1" url = "^2.5" -uuid = { version = "^1.8", features = ["serde", "v4"] } reqwest = { version = "^0.12", default-features = false, features = ["json", "cookies", "multipart"] } -[dev-dependencies] -tokio = { version = '1', features = ['macros', 'rt-multi-thread'] } [features] -default = ["reqwest/default"] \ No newline at end of file +default = ["native-tls"] +native-tls = ["reqwest/native-tls"] +rustls-tls = ["reqwest/rustls-tls"] + +[dev-dependencies] +tokio = { version = '1', features = ['macros', 'rt-multi-thread'] } \ No newline at end of file diff --git a/docs/GroupSearchSort.md b/docs/GroupSearchSort.md index ffe0c07..69c1724 100644 --- a/docs/GroupSearchSort.md +++ b/docs/GroupSearchSort.md @@ -4,8 +4,8 @@ | Name | Value | |---- | -----| -| Asc | joinedAt:asc | -| Desc | joinedAt:desc | +| JoinedAtColonAsc | joinedAt:asc | +| JoinedAtColonDesc | joinedAt:desc | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/src/apis/authentication_api.rs b/src/apis/authentication_api.rs index f3d41ad..1a865d2 100644 --- a/src/apis/authentication_api.rs +++ b/src/apis/authentication_api.rs @@ -6,10 +6,10 @@ * Generated by: https://openapi-generator.tech */ -use super::{configuration, Error}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; use reqwest; -use serde::{Deserialize, Serialize}; +use serde::{de::Error as _, Deserialize, Serialize}; /// struct for typed errors of method [`cancel_pending2_fa`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -157,39 +157,44 @@ pub enum VerifyRecoveryCodeError { pub async fn cancel_pending2_fa( configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/auth/twofactorauth/totp/pending", - local_var_configuration.base_path + 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + 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 `models::Disable2FaResult`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Disable2FaResult`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -201,52 +206,57 @@ pub async fn check_user_exists( username: Option<&str>, exclude_user_id: Option<&str>, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_email = email; + let p_query_display_name = display_name; + let p_query_username = username; + let p_query_exclude_user_id = exclude_user_id; - let local_var_client = &local_var_configuration.client; + let uri_str = format!("{}/auth/exists", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_uri_str = format!("{}/auth/exists", 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_str) = email { - local_var_req_builder = - local_var_req_builder.query(&[("email", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_email { + req_builder = req_builder.query(&[("email", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = display_name { - local_var_req_builder = - local_var_req_builder.query(&[("displayName", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_display_name { + req_builder = req_builder.query(&[("displayName", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = username { - local_var_req_builder = - local_var_req_builder.query(&[("username", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_username { + req_builder = req_builder.query(&[("username", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = exclude_user_id { - local_var_req_builder = - local_var_req_builder.query(&[("excludeUserId", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_exclude_user_id { + req_builder = req_builder.query(&[("excludeUserId", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::UserExists`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UserExists`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -256,39 +266,34 @@ pub async fn confirm_email( id: &str, verify_email: &str, ) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_id = id; + let p_query_verify_email = verify_email; - let local_var_uri_str = format!("{}/auth/confirmEmail", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/auth/confirmEmail", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - local_var_req_builder = local_var_req_builder.query(&[("id", &id.to_string())]); - local_var_req_builder = - local_var_req_builder.query(&[("verify_email", &verify_email.to_string())]); - 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()); + req_builder = req_builder.query(&[("id", &p_query_id.to_string())]); + req_builder = req_builder.query(&[("verify_email", &p_query_verify_email.to_string())]); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -297,40 +302,46 @@ pub async fn delete_user( configuration: &configuration::Configuration, user_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/users/{userId}/delete", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + 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 `models::CurrentUser`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CurrentUser`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -338,36 +349,41 @@ pub async fn delete_user( pub async fn disable2_fa( configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/auth/twofactorauth", 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let uri_str = format!("{}/auth/twofactorauth", configuration.base_path); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + 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 `models::Disable2FaResult`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Disable2FaResult`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -375,39 +391,44 @@ pub async fn disable2_fa( pub async fn enable2_fa( configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/auth/twofactorauth/totp/pending", - local_var_configuration.base_path + 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::Pending2FaResult`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Pending2FaResult`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -415,42 +436,42 @@ pub async fn enable2_fa( pub async fn get_current_user( configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/auth/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()); + let uri_str = format!("{}/auth/user", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { - local_var_req_builder = local_var_req_builder.basic_auth( - local_var_auth_conf.0.to_owned(), - local_var_auth_conf.1.to_owned(), - ); + if let Some(ref auth_conf) = configuration.basic_auth { + req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.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 = local_var_resp.text().await?; - - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::CurrentUser`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CurrentUser`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -458,39 +479,39 @@ pub async fn get_current_user( pub async fn get_global_avatar_moderations( configuration: &configuration::Configuration, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/auth/user/avatarmoderations", - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let uri_str = format!("{}/auth/user/avatarmoderations", 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()); + } + + 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<models::AvatarModeration>`"))), + 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<models::AvatarModeration>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -498,39 +519,39 @@ pub async fn get_global_avatar_moderations( pub async fn get_recovery_codes( configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/auth/user/twofactorauth/otp", - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let uri_str = format!("{}/auth/user/twofactorauth/otp", 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()); + } + + 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 `models::TwoFactorRecoveryCodes`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorRecoveryCodes`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -538,74 +559,87 @@ pub async fn get_recovery_codes( pub async fn logout( configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/logout", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let uri_str = format!("{}/logout", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + 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 `models::Success`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Success`")))), + } } else { - let local_var_entity: Option = 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } /// ~~Register a new user account.~~ **DEPRECATED:** Automated creation of accounts has no legitimate public third-party use case, and would be in violation of ToS ยง13.2: *By using the Platform, you agree not to: i. [...] use the Platform in a manner inconsistent with individual human usage* This endpoint is documented in the interest of completeness +#[deprecated] pub async fn register_user_account( configuration: &configuration::Configuration, register_user_account_request: models::RegisterUserAccountRequest, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/auth/register", 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()); - } - local_var_req_builder = local_var_req_builder.json(®ister_user_account_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + // add a prefix to parameters to efficiently prevent name collisions + let p_body_register_user_account_request = register_user_account_request; + + let uri_str = format!("{}/auth/register", 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()); + } + req_builder = req_builder.json(&p_body_register_user_account_request); + + 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 `models::CurrentUser`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CurrentUser`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -613,39 +647,41 @@ pub async fn register_user_account( pub async fn resend_email_confirmation( configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/auth/user/resendEmail", - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let uri_str = format!("{}/auth/user/resendEmail", 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()); + } + + 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 `models::Success`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Success`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -654,40 +690,45 @@ pub async fn verify2_fa( configuration: &configuration::Configuration, two_factor_auth_code: models::TwoFactorAuthCode, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/auth/twofactorauth/totp/verify", - 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()); - } - local_var_req_builder = local_var_req_builder.json(&two_factor_auth_code); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + // add a prefix to parameters to efficiently prevent name collisions + let p_body_two_factor_auth_code = two_factor_auth_code; + + let uri_str = format!("{}/auth/twofactorauth/totp/verify", 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()); + } + req_builder = req_builder.json(&p_body_two_factor_auth_code); + + 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 `models::Verify2FaResult`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Verify2FaResult`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -696,40 +737,48 @@ pub async fn verify2_fa_email_code( configuration: &configuration::Configuration, two_factor_email_code: models::TwoFactorEmailCode, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_body_two_factor_email_code = two_factor_email_code; - let local_var_uri_str = format!( + let uri_str = format!( "{}/auth/twofactorauth/emailotp/verify", - local_var_configuration.base_path + 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()); - } - local_var_req_builder = local_var_req_builder.json(&two_factor_email_code); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + req_builder = req_builder.json(&p_body_two_factor_email_code); + + 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 `models::Verify2FaEmailCodeResult`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Verify2FaEmailCodeResult`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -737,36 +786,39 @@ pub async fn verify2_fa_email_code( pub async fn verify_auth_token( configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/auth", 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let uri_str = format!("{}/auth", 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()); + } + + 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 `models::VerifyAuthTokenResult`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::VerifyAuthTokenResult`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -776,44 +828,36 @@ pub async fn verify_login_place( token: &str, user_id: Option<&str>, ) -> Result<(), Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_token = token; + let p_query_user_id = user_id; - let local_var_client = &local_var_configuration.client; + let uri_str = format!("{}/auth/verifyLoginPlace", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_uri_str = format!( - "{}/auth/verifyLoginPlace", - 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_str) = user_id { - local_var_req_builder = - local_var_req_builder.query(&[("userId", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_user_id { + req_builder = req_builder.query(&[("userId", ¶m_value.to_string())]); } - local_var_req_builder = local_var_req_builder.query(&[("token", &token.to_string())]); - 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()); + req_builder = req_builder.query(&[("token", &p_query_token.to_string())]); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -822,40 +866,48 @@ pub async fn verify_pending2_fa( configuration: &configuration::Configuration, two_factor_auth_code: models::TwoFactorAuthCode, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_body_two_factor_auth_code = two_factor_auth_code; - let local_var_uri_str = format!( + let uri_str = format!( "{}/auth/twofactorauth/totp/pending/verify", - local_var_configuration.base_path + 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()); - } - local_var_req_builder = local_var_req_builder.json(&two_factor_auth_code); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + req_builder = req_builder.json(&p_body_two_factor_auth_code); + + 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 `models::Verify2FaResult`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Verify2FaResult`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -864,39 +916,44 @@ pub async fn verify_recovery_code( configuration: &configuration::Configuration, two_factor_auth_code: models::TwoFactorAuthCode, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/auth/twofactorauth/otp/verify", - 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()); - } - local_var_req_builder = local_var_req_builder.json(&two_factor_auth_code); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + // add a prefix to parameters to efficiently prevent name collisions + let p_body_two_factor_auth_code = two_factor_auth_code; + + let uri_str = format!("{}/auth/twofactorauth/otp/verify", 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()); + } + req_builder = req_builder.json(&p_body_two_factor_auth_code); + + 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 `models::Verify2FaResult`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Verify2FaResult`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } diff --git a/src/apis/avatars_api.rs b/src/apis/avatars_api.rs index e49497e..fed49a7 100644 --- a/src/apis/avatars_api.rs +++ b/src/apis/avatars_api.rs @@ -6,10 +6,10 @@ * Generated by: https://openapi-generator.tech */ -use super::{configuration, Error}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; use reqwest; -use serde::{Deserialize, Serialize}; +use serde::{de::Error as _, Deserialize, Serialize}; /// struct for typed errors of method [`create_avatar`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -138,37 +138,45 @@ pub async fn create_avatar( configuration: &configuration::Configuration, create_avatar_request: Option, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/avatars", 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()); - } - local_var_req_builder = local_var_req_builder.json(&create_avatar_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + // add a prefix to parameters to efficiently prevent name collisions + let p_body_create_avatar_request = create_avatar_request; + + let uri_str = format!("{}/avatars", 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()); + } + req_builder = req_builder.json(&p_body_create_avatar_request); + + 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 `models::Avatar`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Avatar`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -177,40 +185,48 @@ pub async fn delete_avatar( configuration: &configuration::Configuration, avatar_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_avatar_id = avatar_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/avatars/{avatarId}", - local_var_configuration.base_path, - avatarId = crate::apis::urlencode(avatar_id) + configuration.base_path, + avatarId = crate::apis::urlencode(p_path_avatar_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + 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 `models::Avatar`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Avatar`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -219,40 +235,37 @@ pub async fn delete_impostor( configuration: &configuration::Configuration, avatar_id: &str, ) -> Result<(), Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_avatar_id = avatar_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/avatars/{avatarId}/impostor", - local_var_configuration.base_path, - avatarId = crate::apis::urlencode(avatar_id) + configuration.base_path, + avatarId = crate::apis::urlencode(p_path_avatar_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -261,40 +274,48 @@ pub async fn enqueue_impostor( configuration: &configuration::Configuration, avatar_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_avatar_id = avatar_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/avatars/{avatarId}/impostor/enqueue", - local_var_configuration.base_path, - avatarId = crate::apis::urlencode(avatar_id) + configuration.base_path, + avatarId = crate::apis::urlencode(p_path_avatar_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::ServiceStatus`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ServiceStatus`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -303,40 +324,46 @@ pub async fn get_avatar( configuration: &configuration::Configuration, avatar_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_avatar_id = avatar_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/avatars/{avatarId}", - local_var_configuration.base_path, - avatarId = crate::apis::urlencode(avatar_id) + configuration.base_path, + avatarId = crate::apis::urlencode(p_path_avatar_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::Avatar`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Avatar`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -344,36 +371,39 @@ pub async fn get_avatar( pub async fn get_avatar_styles( configuration: &configuration::Configuration, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/avatarStyles", 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let uri_str = format!("{}/avatarStyles", 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()); + } + + 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<models::AvatarStyle>`"))), + 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<models::AvatarStyle>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -394,86 +424,93 @@ pub async fn get_favorited_avatars( platform: Option<&str>, user_id: Option<&str>, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_featured = featured; + let p_query_sort = sort; + let p_query_n = n; + let p_query_order = order; + let p_query_offset = offset; + let p_query_search = search; + let p_query_tag = tag; + let p_query_notag = notag; + let p_query_release_status = release_status; + let p_query_max_unity_version = max_unity_version; + let p_query_min_unity_version = min_unity_version; + let p_query_platform = platform; + let p_query_user_id = user_id; - let local_var_uri_str = format!("{}/avatars/favorites", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/avatars/favorites", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = featured { - local_var_req_builder = - local_var_req_builder.query(&[("featured", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_featured { + req_builder = req_builder.query(&[("featured", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = sort { - local_var_req_builder = - local_var_req_builder.query(&[("sort", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_sort { + req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = order { - local_var_req_builder = - local_var_req_builder.query(&[("order", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_order { + req_builder = req_builder.query(&[("order", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = search { - local_var_req_builder = - local_var_req_builder.query(&[("search", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_search { + req_builder = req_builder.query(&[("search", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = tag { - local_var_req_builder = local_var_req_builder.query(&[("tag", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_tag { + req_builder = req_builder.query(&[("tag", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = notag { - local_var_req_builder = - local_var_req_builder.query(&[("notag", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_notag { + req_builder = req_builder.query(&[("notag", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = release_status { - local_var_req_builder = - local_var_req_builder.query(&[("releaseStatus", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_release_status { + req_builder = req_builder.query(&[("releaseStatus", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = max_unity_version { - local_var_req_builder = - local_var_req_builder.query(&[("maxUnityVersion", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_max_unity_version { + req_builder = req_builder.query(&[("maxUnityVersion", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = min_unity_version { - local_var_req_builder = - local_var_req_builder.query(&[("minUnityVersion", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_min_unity_version { + req_builder = req_builder.query(&[("minUnityVersion", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = platform { - local_var_req_builder = - local_var_req_builder.query(&[("platform", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_platform { + req_builder = req_builder.query(&[("platform", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = user_id { - local_var_req_builder = - local_var_req_builder.query(&[("userId", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_user_id { + req_builder = req_builder.query(&[("userId", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::Avatar>`"))), + 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<models::Avatar>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -481,39 +518,39 @@ pub async fn get_favorited_avatars( pub async fn get_impostor_queue_stats( configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/avatars/impostor/queue/stats", - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let uri_str = format!("{}/avatars/impostor/queue/stats", 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()); + } + + 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 `models::ServiceQueueStats`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ServiceQueueStats`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -523,43 +560,49 @@ pub async fn get_licensed_avatars( n: Option, offset: Option, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_n = n; + let p_query_offset = offset; - let local_var_uri_str = format!("{}/avatars/licensed", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/avatars/licensed", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::Avatar>`"))), + 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<models::Avatar>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -568,40 +611,46 @@ pub async fn get_own_avatar( configuration: &configuration::Configuration, user_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/users/{userId}/avatar", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::Avatar`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Avatar`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -622,86 +671,93 @@ pub async fn search_avatars( min_unity_version: Option<&str>, platform: Option<&str>, ) -> Result, Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_featured = featured; + let p_query_sort = sort; + let p_query_user = user; + let p_query_user_id = user_id; + let p_query_n = n; + let p_query_order = order; + let p_query_offset = offset; + let p_query_tag = tag; + let p_query_notag = notag; + let p_query_release_status = release_status; + let p_query_max_unity_version = max_unity_version; + let p_query_min_unity_version = min_unity_version; + let p_query_platform = platform; - let local_var_client = &local_var_configuration.client; + let uri_str = format!("{}/avatars", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_uri_str = format!("{}/avatars", 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_str) = featured { - local_var_req_builder = - local_var_req_builder.query(&[("featured", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_featured { + req_builder = req_builder.query(&[("featured", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = sort { - local_var_req_builder = - local_var_req_builder.query(&[("sort", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_sort { + req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = user { - local_var_req_builder = - local_var_req_builder.query(&[("user", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_user { + req_builder = req_builder.query(&[("user", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = user_id { - local_var_req_builder = - local_var_req_builder.query(&[("userId", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_user_id { + req_builder = req_builder.query(&[("userId", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = order { - local_var_req_builder = - local_var_req_builder.query(&[("order", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_order { + req_builder = req_builder.query(&[("order", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = tag { - local_var_req_builder = local_var_req_builder.query(&[("tag", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_tag { + req_builder = req_builder.query(&[("tag", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = notag { - local_var_req_builder = - local_var_req_builder.query(&[("notag", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_notag { + req_builder = req_builder.query(&[("notag", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = release_status { - local_var_req_builder = - local_var_req_builder.query(&[("releaseStatus", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_release_status { + req_builder = req_builder.query(&[("releaseStatus", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = max_unity_version { - local_var_req_builder = - local_var_req_builder.query(&[("maxUnityVersion", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_max_unity_version { + req_builder = req_builder.query(&[("maxUnityVersion", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = min_unity_version { - local_var_req_builder = - local_var_req_builder.query(&[("minUnityVersion", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_min_unity_version { + req_builder = req_builder.query(&[("minUnityVersion", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = platform { - local_var_req_builder = - local_var_req_builder.query(&[("platform", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_platform { + req_builder = req_builder.query(&[("platform", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::Avatar>`"))), + 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<models::Avatar>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -710,82 +766,95 @@ pub async fn select_avatar( configuration: &configuration::Configuration, avatar_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_avatar_id = avatar_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/avatars/{avatarId}/select", - local_var_configuration.base_path, - avatarId = crate::apis::urlencode(avatar_id) + configuration.base_path, + avatarId = crate::apis::urlencode(p_path_avatar_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + 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 `models::CurrentUser`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CurrentUser`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } /// Switches into that avatar as your fallback avatar. +#[deprecated] pub async fn select_fallback_avatar( configuration: &configuration::Configuration, avatar_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_avatar_id = avatar_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/avatars/{avatarId}/selectFallback", - local_var_configuration.base_path, - avatarId = crate::apis::urlencode(avatar_id) + configuration.base_path, + avatarId = crate::apis::urlencode(p_path_avatar_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + 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 `models::CurrentUser`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CurrentUser`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -795,40 +864,47 @@ pub async fn update_avatar( avatar_id: &str, update_avatar_request: Option, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_avatar_id = avatar_id; + let p_body_update_avatar_request = update_avatar_request; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/avatars/{avatarId}", - local_var_configuration.base_path, - avatarId = crate::apis::urlencode(avatar_id) + configuration.base_path, + avatarId = crate::apis::urlencode(p_path_avatar_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, 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(&update_avatar_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(&p_body_update_avatar_request); + + 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 `models::Avatar`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Avatar`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } diff --git a/src/apis/calendar_api.rs b/src/apis/calendar_api.rs index 4bcb3c7..00e0bc9 100644 --- a/src/apis/calendar_api.rs +++ b/src/apis/calendar_api.rs @@ -6,10 +6,10 @@ * Generated by: https://openapi-generator.tech */ -use super::{configuration, Error}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; use reqwest; -use serde::{Deserialize, Serialize}; +use serde::{de::Error as _, Deserialize, Serialize}; /// struct for typed errors of method [`create_group_calendar_event`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -106,41 +106,50 @@ pub async fn create_group_calendar_event( group_id: &str, create_calendar_event_request: models::CreateCalendarEventRequest, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_body_create_calendar_event_request = create_calendar_event_request; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/calendar/{groupId}/event", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - 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()); - } - local_var_req_builder = local_var_req_builder.json(&create_calendar_event_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + req_builder = req_builder.json(&p_body_create_calendar_event_request); + + 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 `models::CalendarEvent`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CalendarEvent`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -150,41 +159,50 @@ pub async fn delete_group_calendar_event( group_id: &str, calendar_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_calendar_id = calendar_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/calendar/{groupId}/{calendarId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - calendarId = crate::apis::urlencode(calendar_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + calendarId = crate::apis::urlencode(p_path_calendar_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + 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 `models::Success`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Success`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -195,42 +213,52 @@ pub async fn follow_group_calendar_event( calendar_id: &str, follow_calendar_event_request: models::FollowCalendarEventRequest, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_calendar_id = calendar_id; + let p_body_follow_calendar_event_request = follow_calendar_event_request; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/calendar/{groupId}/{calendarId}/follow", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - calendarId = crate::apis::urlencode(calendar_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + calendarId = crate::apis::urlencode(p_path_calendar_id) ); - 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()); - } - local_var_req_builder = local_var_req_builder.json(&follow_calendar_event_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + req_builder = req_builder.json(&p_body_follow_calendar_event_request); + + 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 `models::CalendarEvent`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CalendarEvent`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -241,47 +269,53 @@ pub async fn get_calendar_events( n: Option, offset: Option, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_date = date; + let p_query_n = n; + let p_query_offset = offset; - let local_var_client = &local_var_configuration.client; + let uri_str = format!("{}/calendar", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_uri_str = format!("{}/calendar", 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_str) = date { - local_var_req_builder = - local_var_req_builder.query(&[("date", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_date { + req_builder = req_builder.query(&[("date", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::PaginatedCalendarEventList`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PaginatedCalendarEventList`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -292,47 +326,53 @@ pub async fn get_featured_calendar_events( n: Option, offset: Option, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_date = date; + let p_query_n = n; + let p_query_offset = offset; - let local_var_uri_str = format!("{}/calendar/featured", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/calendar/featured", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = date { - local_var_req_builder = - local_var_req_builder.query(&[("date", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_date { + req_builder = req_builder.query(&[("date", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::PaginatedCalendarEventList`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PaginatedCalendarEventList`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -343,47 +383,53 @@ pub async fn get_followed_calendar_events( n: Option, offset: Option, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_date = date; + let p_query_n = n; + let p_query_offset = offset; - let local_var_uri_str = format!("{}/calendar/following", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/calendar/following", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = date { - local_var_req_builder = - local_var_req_builder.query(&[("date", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_date { + req_builder = req_builder.query(&[("date", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::PaginatedCalendarEventList`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PaginatedCalendarEventList`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -393,41 +439,48 @@ pub async fn get_group_calendar_event( group_id: &str, calendar_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_calendar_id = calendar_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/calendar/{groupId}/{calendarId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - calendarId = crate::apis::urlencode(calendar_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + calendarId = crate::apis::urlencode(p_path_calendar_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::CalendarEvent`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CalendarEvent`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -436,42 +489,38 @@ pub async fn get_group_calendar_event_ics( configuration: &configuration::Configuration, group_id: &str, calendar_id: &str, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_calendar_id = calendar_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/calendar/{groupId}/{calendarId}.ics", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - calendarId = crate::apis::urlencode(calendar_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + calendarId = crate::apis::urlencode(p_path_calendar_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + Ok(resp) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -483,51 +532,58 @@ pub async fn get_group_calendar_events( n: Option, offset: Option, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_query_date = date; + let p_query_n = n; + let p_query_offset = offset; - let local_var_uri_str = format!( + let uri_str = format!( "{}/calendar/{groupId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = date { - local_var_req_builder = - local_var_req_builder.query(&[("date", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_date { + req_builder = req_builder.query(&[("date", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::PaginatedCalendarEventList`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PaginatedCalendarEventList`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -539,49 +595,55 @@ pub async fn search_calendar_events( n: Option, offset: Option, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/calendar/search", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - local_var_req_builder = - local_var_req_builder.query(&[("searchTerm", &search_term.to_string())]); - if let Some(ref local_var_str) = utc_offset { - local_var_req_builder = - local_var_req_builder.query(&[("utcOffset", &local_var_str.to_string())]); - } - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); - } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); - } - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + // add a prefix to parameters to efficiently prevent name collisions + let p_query_search_term = search_term; + let p_query_utc_offset = utc_offset; + let p_query_n = n; + let p_query_offset = offset; + + let uri_str = format!("{}/calendar/search", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + req_builder = req_builder.query(&[("searchTerm", &p_query_search_term.to_string())]); + if let Some(ref param_value) = p_query_utc_offset { + req_builder = req_builder.query(&[("utcOffset", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + 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 `models::PaginatedCalendarEventList`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PaginatedCalendarEventList`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -592,41 +654,49 @@ pub async fn update_group_calendar_event( calendar_id: &str, update_calendar_event_request: models::UpdateCalendarEventRequest, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_calendar_id = calendar_id; + let p_body_update_calendar_event_request = update_calendar_event_request; - let local_var_uri_str = format!( + let uri_str = format!( "{}/calendar/{groupId}/{calendarId}/event", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - calendarId = crate::apis::urlencode(calendar_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + calendarId = crate::apis::urlencode(p_path_calendar_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, 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(&update_calendar_event_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(&p_body_update_calendar_event_request); + + 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 `models::CalendarEvent`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CalendarEvent`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } diff --git a/src/apis/configuration.rs b/src/apis/configuration.rs index f01173e..f61fe1d 100644 --- a/src/apis/configuration.rs +++ b/src/apis/configuration.rs @@ -15,7 +15,6 @@ pub struct Configuration { pub oauth_access_token: Option, pub bearer_access_token: Option, pub api_key: Option, - // TODO: take an oauth2 token source, similar to the go one } pub type BasicAuth = (String, Option); diff --git a/src/apis/economy_api.rs b/src/apis/economy_api.rs index e737102..554c730 100644 --- a/src/apis/economy_api.rs +++ b/src/apis/economy_api.rs @@ -6,10 +6,10 @@ * Generated by: https://openapi-generator.tech */ -use super::{configuration, Error}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; use reqwest; -use serde::{Deserialize, Serialize}; +use serde::{de::Error as _, Deserialize, Serialize}; /// struct for typed errors of method [`get_active_licenses`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -151,39 +151,39 @@ pub enum GetUserSubscriptionEligibleError { pub async fn get_active_licenses( configuration: &configuration::Configuration, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/economy/licenses/active", - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let uri_str = format!("{}/economy/licenses/active", 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()); + } + + 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<models::License>`"))), + 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<models::License>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -192,40 +192,46 @@ pub async fn get_balance( configuration: &configuration::Configuration, user_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/user/{userId}/balance", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::Balance`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Balance`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -234,40 +240,46 @@ pub async fn get_balance_earnings( configuration: &configuration::Configuration, user_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/user/{userId}/balance/earnings", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::Balance`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Balance`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -275,39 +287,39 @@ pub async fn get_balance_earnings( pub async fn get_current_subscriptions( configuration: &configuration::Configuration, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/auth/user/subscription", - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let uri_str = format!("{}/auth/user/subscription", 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()); + } + + 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<models::UserSubscription>`"))), + 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<models::UserSubscription>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -316,40 +328,46 @@ pub async fn get_economy_account( configuration: &configuration::Configuration, user_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/user/{userId}/economy/account", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::EconomyAccount`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EconomyAccount`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -358,40 +376,46 @@ pub async fn get_license_group( configuration: &configuration::Configuration, license_group_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_license_group_id = license_group_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/licenseGroups/{licenseGroupId}", - local_var_configuration.base_path, - licenseGroupId = crate::apis::urlencode(license_group_id) + configuration.base_path, + licenseGroupId = crate::apis::urlencode(p_path_license_group_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::LicenseGroup`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LicenseGroup`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -401,44 +425,50 @@ pub async fn get_product_listing( product_id: &str, hydrate: Option, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_product_id = product_id; + let p_query_hydrate = hydrate; - let local_var_uri_str = format!( + let uri_str = format!( "{}/listing/{productId}", - local_var_configuration.base_path, - productId = crate::apis::urlencode(product_id) + configuration.base_path, + productId = crate::apis::urlencode(p_path_product_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = hydrate { - local_var_req_builder = - local_var_req_builder.query(&[("hydrate", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_hydrate { + req_builder = req_builder.query(&[("hydrate", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::ProductListing`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProductListing`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -452,101 +482,115 @@ pub async fn get_product_listings( group_id: Option<&str>, active: Option, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + let p_query_n = n; + let p_query_offset = offset; + let p_query_hydrate = hydrate; + let p_query_group_id = group_id; + let p_query_active = active; + + let uri_str = format!( "{}/user/{userId}/listings", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = hydrate { - local_var_req_builder = - local_var_req_builder.query(&[("hydrate", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_hydrate { + req_builder = req_builder.query(&[("hydrate", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = group_id { - local_var_req_builder = - local_var_req_builder.query(&[("groupId", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_group_id { + req_builder = req_builder.query(&[("groupId", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = active { - local_var_req_builder = - local_var_req_builder.query(&[("active", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_active { + req_builder = req_builder.query(&[("active", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::ProductListing>`"))), + 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<models::ProductListing>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } /// Get a single Steam transactions by ID. This returns the exact same information as `getSteamTransactions`, so no point in using this endpoint. +#[deprecated] pub async fn get_steam_transaction( configuration: &configuration::Configuration, transaction_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_transaction_id = transaction_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/Steam/transactions/{transactionId}", - local_var_configuration.base_path, - transactionId = crate::apis::urlencode(transaction_id) + configuration.base_path, + transactionId = crate::apis::urlencode(p_path_transaction_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::Transaction`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Transaction`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -554,36 +598,39 @@ pub async fn get_steam_transaction( pub async fn get_steam_transactions( configuration: &configuration::Configuration, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/Steam/transactions", 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let uri_str = format!("{}/Steam/transactions", 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()); + } + + 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<models::Transaction>`"))), + 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<models::Transaction>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -594,44 +641,51 @@ pub async fn get_store( hydrate_listings: Option, hydrate_products: Option, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/economy/store", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - local_var_req_builder = local_var_req_builder.query(&[("storeId", &store_id.to_string())]); - if let Some(ref local_var_str) = hydrate_listings { - local_var_req_builder = - local_var_req_builder.query(&[("hydrateListings", &local_var_str.to_string())]); - } - if let Some(ref local_var_str) = hydrate_products { - local_var_req_builder = - local_var_req_builder.query(&[("hydrateProducts", &local_var_str.to_string())]); - } - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + // add a prefix to parameters to efficiently prevent name collisions + let p_query_store_id = store_id; + let p_query_hydrate_listings = hydrate_listings; + let p_query_hydrate_products = hydrate_products; + + let uri_str = format!("{}/economy/store", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + req_builder = req_builder.query(&[("storeId", &p_query_store_id.to_string())]); + if let Some(ref param_value) = p_query_hydrate_listings { + req_builder = req_builder.query(&[("hydrateListings", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_query_hydrate_products { + req_builder = req_builder.query(&[("hydrateProducts", ¶m_value.to_string())]); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + 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 `models::Store`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Store`")))), + } } else { - let local_var_entity: Option = 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -642,48 +696,51 @@ pub async fn get_store_shelves( hydrate_listings: Option, fetch: Option, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/economy/store/shelves", - local_var_configuration.base_path - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - local_var_req_builder = local_var_req_builder.query(&[("storeId", &store_id.to_string())]); - if let Some(ref local_var_str) = hydrate_listings { - local_var_req_builder = - local_var_req_builder.query(&[("hydrateListings", &local_var_str.to_string())]); - } - if let Some(ref local_var_str) = fetch { - local_var_req_builder = - local_var_req_builder.query(&[("fetch", &local_var_str.to_string())]); - } - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + // add a prefix to parameters to efficiently prevent name collisions + let p_query_store_id = store_id; + let p_query_hydrate_listings = hydrate_listings; + let p_query_fetch = fetch; + + let uri_str = format!("{}/economy/store/shelves", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + req_builder = req_builder.query(&[("storeId", &p_query_store_id.to_string())]); + if let Some(ref param_value) = p_query_hydrate_listings { + req_builder = req_builder.query(&[("hydrateListings", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_query_fetch { + req_builder = req_builder.query(&[("fetch", ¶m_value.to_string())]); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + 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<models::StoreShelf>`"))), + 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<models::StoreShelf>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -691,36 +748,39 @@ pub async fn get_store_shelves( pub async fn get_subscriptions( configuration: &configuration::Configuration, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/subscriptions", 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let uri_str = format!("{}/subscriptions", 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()); + } + + 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<models::Subscription>`"))), + 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<models::Subscription>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -728,36 +788,39 @@ pub async fn get_subscriptions( pub async fn get_tilia_status( configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/tilia/status", 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let uri_str = format!("{}/tilia/status", 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()); + } + + 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 `models::TiliaStatus`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TiliaStatus`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -766,40 +829,46 @@ pub async fn get_tilia_tos( configuration: &configuration::Configuration, user_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/user/{userId}/tilia/tos", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::TiliaTos`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TiliaTos`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -807,36 +876,39 @@ pub async fn get_tilia_tos( pub async fn get_token_bundles( configuration: &configuration::Configuration, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/tokenBundles", 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let uri_str = format!("{}/tokenBundles", 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()); + } + + 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<models::TokenBundle>`"))), + 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<models::TokenBundle>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -846,43 +918,49 @@ pub async fn get_user_subscription_eligible( user_id: &str, steam_id: Option<&str>, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + let p_query_steam_id = steam_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/users/{userId}/subscription/eligible", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = steam_id { - local_var_req_builder = - local_var_req_builder.query(&[("steamId", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_steam_id { + req_builder = req_builder.query(&[("steamId", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::UserSubscriptionEligible`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UserSubscriptionEligible`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } diff --git a/src/apis/favorites_api.rs b/src/apis/favorites_api.rs index aab9d2e..911a5ee 100644 --- a/src/apis/favorites_api.rs +++ b/src/apis/favorites_api.rs @@ -6,10 +6,10 @@ * Generated by: https://openapi-generator.tech */ -use super::{configuration, Error}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; use reqwest; -use serde::{Deserialize, Serialize}; +use serde::{de::Error as _, Deserialize, Serialize}; /// struct for typed errors of method [`add_favorite`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -79,37 +79,45 @@ pub async fn add_favorite( configuration: &configuration::Configuration, add_favorite_request: Option, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_body_add_favorite_request = add_favorite_request; - let local_var_client = &local_var_configuration.client; + let uri_str = format!("{}/favorites", configuration.base_path); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); - let local_var_uri_str = format!("{}/favorites", 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&add_favorite_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + req_builder = req_builder.json(&p_body_add_favorite_request); + + 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 `models::Favorite`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Favorite`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -120,42 +128,52 @@ pub async fn clear_favorite_group( favorite_group_name: &str, user_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_favorite_group_type = favorite_group_type; + let p_path_favorite_group_name = favorite_group_name; + let p_path_user_id = user_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/favorite/group/{favoriteGroupType}/{favoriteGroupName}/{userId}", - local_var_configuration.base_path, - favoriteGroupType = crate::apis::urlencode(favorite_group_type), - favoriteGroupName = crate::apis::urlencode(favorite_group_name), - userId = crate::apis::urlencode(user_id) + configuration.base_path, + favoriteGroupType = crate::apis::urlencode(p_path_favorite_group_type), + favoriteGroupName = crate::apis::urlencode(p_path_favorite_group_name), + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::Success`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Success`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -166,42 +184,50 @@ pub async fn get_favorite_group( favorite_group_name: &str, user_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_favorite_group_type = favorite_group_type; + let p_path_favorite_group_name = favorite_group_name; + let p_path_user_id = user_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/favorite/group/{favoriteGroupType}/{favoriteGroupName}/{userId}", - local_var_configuration.base_path, - favoriteGroupType = crate::apis::urlencode(favorite_group_type), - favoriteGroupName = crate::apis::urlencode(favorite_group_name), - userId = crate::apis::urlencode(user_id) + configuration.base_path, + favoriteGroupType = crate::apis::urlencode(p_path_favorite_group_type), + favoriteGroupName = crate::apis::urlencode(p_path_favorite_group_name), + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::FavoriteGroup`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FavoriteGroup`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -213,51 +239,57 @@ pub async fn get_favorite_groups( user_id: Option<&str>, owner_id: Option<&str>, ) -> Result, Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_n = n; + let p_query_offset = offset; + let p_query_user_id = user_id; + let p_query_owner_id = owner_id; - let local_var_client = &local_var_configuration.client; + let uri_str = format!("{}/favorite/groups", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_uri_str = format!("{}/favorite/groups", 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_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = user_id { - local_var_req_builder = - local_var_req_builder.query(&[("userId", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_user_id { + req_builder = req_builder.query(&[("userId", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = owner_id { - local_var_req_builder = - local_var_req_builder.query(&[("ownerId", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_owner_id { + req_builder = req_builder.query(&[("ownerId", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::FavoriteGroup>`"))), + 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<models::FavoriteGroup>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -265,39 +297,39 @@ pub async fn get_favorite_groups( pub async fn get_favorite_limits( configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/auth/user/favoritelimits", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/auth/user/favoritelimits", - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::FavoriteLimits`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FavoriteLimits`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -309,50 +341,57 @@ pub async fn get_favorites( r#type: Option<&str>, tag: Option<&str>, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_n = n; + let p_query_offset = offset; + let p_query_type = r#type; + let p_query_tag = tag; - let local_var_uri_str = format!("{}/favorites", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/favorites", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = r#type { - local_var_req_builder = - local_var_req_builder.query(&[("type", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_type { + req_builder = req_builder.query(&[("type", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = tag { - local_var_req_builder = local_var_req_builder.query(&[("tag", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_tag { + req_builder = req_builder.query(&[("tag", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::Favorite>`"))), + 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<models::Favorite>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -361,40 +400,48 @@ pub async fn remove_favorite( configuration: &configuration::Configuration, favorite_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_favorite_id = favorite_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/favorites/{favoriteId}", - local_var_configuration.base_path, - favoriteId = crate::apis::urlencode(favorite_id) + configuration.base_path, + favoriteId = crate::apis::urlencode(p_path_favorite_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::Success`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Success`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -406,42 +453,40 @@ pub async fn update_favorite_group( user_id: &str, update_favorite_group_request: Option, ) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_favorite_group_type = favorite_group_type; + let p_path_favorite_group_name = favorite_group_name; + let p_path_user_id = user_id; + let p_body_update_favorite_group_request = update_favorite_group_request; - let local_var_uri_str = format!( + let uri_str = format!( "{}/favorite/group/{favoriteGroupType}/{favoriteGroupName}/{userId}", - local_var_configuration.base_path, - favoriteGroupType = crate::apis::urlencode(favorite_group_type), - favoriteGroupName = crate::apis::urlencode(favorite_group_name), - userId = crate::apis::urlencode(user_id) + configuration.base_path, + favoriteGroupType = crate::apis::urlencode(p_path_favorite_group_type), + favoriteGroupName = crate::apis::urlencode(p_path_favorite_group_name), + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&update_favorite_group_request); + req_builder = req_builder.json(&p_body_update_favorite_group_request); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } diff --git a/src/apis/files_api.rs b/src/apis/files_api.rs index f719fad..2aed8cc 100644 --- a/src/apis/files_api.rs +++ b/src/apis/files_api.rs @@ -6,10 +6,10 @@ * Generated by: https://openapi-generator.tech */ -use super::{configuration, Error}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; use reqwest; -use serde::{Deserialize, Serialize}; +use serde::{de::Error as _, Deserialize, Serialize}; /// struct for typed errors of method [`create_file`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -144,39 +144,45 @@ pub async fn create_file( configuration: &configuration::Configuration, create_file_request: Option, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_body_create_file_request = create_file_request; - let local_var_client = &local_var_configuration.client; + let uri_str = format!("{}/file", configuration.base_path); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); - let local_var_uri_str = format!("{}/file", 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(create_file_request) = create_file_request { - local_var_req_builder = local_var_req_builder.json(&create_file_request); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + req_builder = req_builder.json(&p_body_create_file_request); + + 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 `models::File`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::File`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -186,43 +192,50 @@ pub async fn create_file_version( file_id: &str, create_file_version_request: Option, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_file_id = file_id; + let p_body_create_file_version_request = create_file_version_request; - let local_var_uri_str = format!( + let uri_str = format!( "{}/file/{fileId}", - local_var_configuration.base_path, - fileId = crate::apis::urlencode(file_id) + configuration.base_path, + fileId = crate::apis::urlencode(p_path_file_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(create_file_version_request) = create_file_version_request { - local_var_req_builder = local_var_req_builder.json(&create_file_version_request); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + req_builder = req_builder.json(&p_body_create_file_version_request); + + 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 `models::File`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::File`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -231,40 +244,48 @@ pub async fn delete_file( configuration: &configuration::Configuration, file_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_file_id = file_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/file/{fileId}", - local_var_configuration.base_path, - fileId = crate::apis::urlencode(file_id) + configuration.base_path, + fileId = crate::apis::urlencode(p_path_file_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::File`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::File`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -274,41 +295,50 @@ pub async fn delete_file_version( file_id: &str, version_id: i32, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_file_id = file_id; + let p_path_version_id = version_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/file/{fileId}/{versionId}", - local_var_configuration.base_path, - fileId = crate::apis::urlencode(file_id), - versionId = version_id + configuration.base_path, + fileId = crate::apis::urlencode(p_path_file_id), + versionId = p_path_version_id ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::File`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::File`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -317,42 +347,38 @@ pub async fn download_file_version( configuration: &configuration::Configuration, file_id: &str, version_id: i32, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_file_id = file_id; + let p_path_version_id = version_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/file/{fileId}/{versionId}", - local_var_configuration.base_path, - fileId = crate::apis::urlencode(file_id), - versionId = version_id + configuration.base_path, + fileId = crate::apis::urlencode(p_path_file_id), + versionId = p_path_version_id ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + Ok(resp) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -364,45 +390,52 @@ pub async fn finish_file_data_upload( file_type: &str, finish_file_data_upload_request: Option, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_file_id = file_id; + let p_path_version_id = version_id; + let p_path_file_type = file_type; + let p_body_finish_file_data_upload_request = finish_file_data_upload_request; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/file/{fileId}/{versionId}/{fileType}/finish", - local_var_configuration.base_path, - fileId = crate::apis::urlencode(file_id), - versionId = version_id, - fileType = crate::apis::urlencode(file_type) + configuration.base_path, + fileId = crate::apis::urlencode(p_path_file_id), + versionId = p_path_version_id, + fileType = crate::apis::urlencode(p_path_file_type) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_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(finish_file_data_upload_request) = finish_file_data_upload_request { - local_var_req_builder = local_var_req_builder.json(&finish_file_data_upload_request); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + req_builder = req_builder.json(&p_body_finish_file_data_upload_request); + + 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 `models::File`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::File`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -411,40 +444,46 @@ pub async fn get_admin_asset_bundle( configuration: &configuration::Configuration, admin_asset_bundle_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_admin_asset_bundle_id = admin_asset_bundle_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/adminassetbundles/{adminAssetBundleId}", - local_var_configuration.base_path, - adminAssetBundleId = crate::apis::urlencode(admin_asset_bundle_id) + configuration.base_path, + adminAssetBundleId = crate::apis::urlencode(p_path_admin_asset_bundle_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::AdminAssetBundle`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AdminAssetBundle`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -453,39 +492,46 @@ pub async fn get_file( configuration: &configuration::Configuration, file_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_file_id = file_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/file/{fileId}", - local_var_configuration.base_path, - fileId = crate::apis::urlencode(file_id) + configuration.base_path, + fileId = crate::apis::urlencode(p_path_file_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::File`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::File`")))), + } } else { - let local_var_entity: Option = 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -495,41 +541,48 @@ pub async fn get_file_analysis( file_id: &str, version_id: i32, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_file_id = file_id; + let p_path_version_id = version_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/analysis/{fileId}/{versionId}", - local_var_configuration.base_path, - fileId = crate::apis::urlencode(file_id), - versionId = version_id + configuration.base_path, + fileId = crate::apis::urlencode(p_path_file_id), + versionId = p_path_version_id ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::FileAnalysis`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FileAnalysis`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -539,41 +592,48 @@ pub async fn get_file_analysis_security( file_id: &str, version_id: i32, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_file_id = file_id; + let p_path_version_id = version_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/analysis/{fileId}/{versionId}/security", - local_var_configuration.base_path, - fileId = crate::apis::urlencode(file_id), - versionId = version_id + configuration.base_path, + fileId = crate::apis::urlencode(p_path_file_id), + versionId = p_path_version_id ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::FileAnalysis`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FileAnalysis`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -583,41 +643,48 @@ pub async fn get_file_analysis_standard( file_id: &str, version_id: i32, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_file_id = file_id; + let p_path_version_id = version_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/analysis/{fileId}/{versionId}/standard", - local_var_configuration.base_path, - fileId = crate::apis::urlencode(file_id), - versionId = version_id + configuration.base_path, + fileId = crate::apis::urlencode(p_path_file_id), + versionId = p_path_version_id ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::FileAnalysis`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FileAnalysis`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -628,42 +695,50 @@ pub async fn get_file_data_upload_status( version_id: i32, file_type: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_file_id = file_id; + let p_path_version_id = version_id; + let p_path_file_type = file_type; - let local_var_uri_str = format!( + let uri_str = format!( "{}/file/{fileId}/{versionId}/{fileType}/status", - local_var_configuration.base_path, - fileId = crate::apis::urlencode(file_id), - versionId = version_id, - fileType = crate::apis::urlencode(file_type) + configuration.base_path, + fileId = crate::apis::urlencode(p_path_file_id), + versionId = p_path_version_id, + fileType = crate::apis::urlencode(p_path_file_type) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::FileVersionUploadStatus`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FileVersionUploadStatus`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -675,49 +750,57 @@ pub async fn get_files( n: Option, offset: Option, ) -> Result, Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_tag = tag; + let p_query_user_id = user_id; + let p_query_n = n; + let p_query_offset = offset; - let local_var_client = &local_var_configuration.client; + let uri_str = format!("{}/files", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_uri_str = format!("{}/files", 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_str) = tag { - local_var_req_builder = local_var_req_builder.query(&[("tag", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_tag { + req_builder = req_builder.query(&[("tag", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = user_id { - local_var_req_builder = - local_var_req_builder.query(&[("userId", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_user_id { + req_builder = req_builder.query(&[("userId", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::File>`"))), + 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<models::File>`")))), + } } else { - let local_var_entity: Option = 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -729,46 +812,54 @@ pub async fn start_file_data_upload( file_type: &str, part_number: Option, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_file_id = file_id; + let p_path_version_id = version_id; + let p_path_file_type = file_type; + let p_query_part_number = part_number; - let local_var_uri_str = format!( + let uri_str = format!( "{}/file/{fileId}/{versionId}/{fileType}/start", - local_var_configuration.base_path, - fileId = crate::apis::urlencode(file_id), - versionId = version_id, - fileType = crate::apis::urlencode(file_type) + configuration.base_path, + fileId = crate::apis::urlencode(p_path_file_id), + versionId = p_path_version_id, + fileType = crate::apis::urlencode(p_path_file_type) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - if let Some(ref local_var_str) = part_number { - local_var_req_builder = - local_var_req_builder.query(&[("partNumber", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_part_number { + req_builder = req_builder.query(&[("partNumber", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::FileUploadUrl`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FileUploadUrl`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -779,42 +870,50 @@ pub async fn upload_gallery_image( filename: impl Into<::std::borrow::Cow<'static, str>>, mime_type: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_form_file = file; - let local_var_uri_str = format!("{}/gallery", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/gallery", configuration.base_path); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let mut local_var_form = reqwest::multipart::Form::new(); - let part = reqwest::multipart::Part::bytes(file) + let mut multipart_form = reqwest::multipart::Form::new(); + let part = reqwest::multipart::Part::bytes(p_form_file) .file_name(filename) .mime_str(mime_type)?; - local_var_form = local_var_form.part("file", part); - local_var_req_builder = local_var_req_builder.multipart(local_var_form); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + multipart_form = multipart_form.part("file", part); + req_builder = req_builder.multipart(multipart_form); + + 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 `models::File`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::File`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -825,42 +924,50 @@ pub async fn upload_icon( filename: impl Into<::std::borrow::Cow<'static, str>>, mime_type: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_form_file = file; - let local_var_uri_str = format!("{}/icon", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/icon", configuration.base_path); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let mut local_var_form = reqwest::multipart::Form::new(); - let part = reqwest::multipart::Part::bytes(file) + let mut multipart_form = reqwest::multipart::Form::new(); + let part = reqwest::multipart::Part::bytes(p_form_file) .file_name(filename) .mime_str(mime_type)?; - local_var_form = local_var_form.part("file", part); - local_var_req_builder = local_var_req_builder.multipart(local_var_form); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + multipart_form = multipart_form.part("file", part); + req_builder = req_builder.multipart(multipart_form); + + 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 `models::File`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::File`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -876,54 +983,67 @@ pub async fn upload_image( animation_style: Option<&str>, mask_tag: Option<&str>, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/file/image", 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()); + // add a prefix to parameters to efficiently prevent name collisions + let p_form_file = file; + let p_form_tag = tag; + let p_form_frames = frames; + let p_form_frames_over_time = frames_over_time; + let p_form_animation_style = animation_style; + let p_form_mask_tag = mask_tag; + + let uri_str = format!("{}/file/image", 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()); } - let mut local_var_form = reqwest::multipart::Form::new(); - let part = reqwest::multipart::Part::bytes(file) + let mut multipart_form = reqwest::multipart::Form::new(); + let part = reqwest::multipart::Part::bytes(p_form_file) .file_name(filename) .mime_str(mime_type)?; - local_var_form = local_var_form.part("file", part); - local_var_form = local_var_form.text("tag", tag.to_string()); - if let Some(local_var_param_value) = frames { - local_var_form = local_var_form.text("frames", local_var_param_value.to_string()); + multipart_form = multipart_form.part("file", part); + multipart_form = multipart_form.text("tag", p_form_tag.to_string()); + if let Some(param_value) = p_form_frames { + multipart_form = multipart_form.text("frames", param_value.to_string()); } - if let Some(local_var_param_value) = frames_over_time { - local_var_form = local_var_form.text("framesOverTime", local_var_param_value.to_string()); + if let Some(param_value) = p_form_frames_over_time { + multipart_form = multipart_form.text("framesOverTime", param_value.to_string()); } - if let Some(local_var_param_value) = animation_style { - local_var_form = local_var_form.text("animationStyle", local_var_param_value.to_string()); + if let Some(param_value) = p_form_animation_style { + multipart_form = multipart_form.text("animationStyle", param_value.to_string()); } - if let Some(local_var_param_value) = mask_tag { - local_var_form = local_var_form.text("maskTag", local_var_param_value.to_string()); + if let Some(param_value) = p_form_mask_tag { + multipart_form = multipart_form.text("maskTag", param_value.to_string()); } - local_var_req_builder = local_var_req_builder.multipart(local_var_form); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + req_builder = req_builder.multipart(multipart_form); + + 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 `models::File`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::File`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } diff --git a/src/apis/friends_api.rs b/src/apis/friends_api.rs index f191b6b..439124d 100644 --- a/src/apis/friends_api.rs +++ b/src/apis/friends_api.rs @@ -6,10 +6,10 @@ * Generated by: https://openapi-generator.tech */ -use super::{configuration, Error}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; use reqwest; -use serde::{Deserialize, Serialize}; +use serde::{de::Error as _, Deserialize, Serialize}; /// struct for typed errors of method [`delete_friend_request`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -60,40 +60,48 @@ pub async fn delete_friend_request( configuration: &configuration::Configuration, user_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/user/{userId}/friendRequest", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::Success`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Success`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -102,39 +110,48 @@ pub async fn friend( configuration: &configuration::Configuration, user_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/user/{userId}/friendRequest", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::Notification`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Notification`")))), + } } else { - let local_var_entity: Option = 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -143,40 +160,46 @@ pub async fn get_friend_status( configuration: &configuration::Configuration, user_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/user/{userId}/friendStatus", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::FriendStatus`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FriendStatus`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -187,47 +210,53 @@ pub async fn get_friends( n: Option, offline: Option, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_offset = offset; + let p_query_n = n; + let p_query_offline = offline; - let local_var_uri_str = format!("{}/auth/user/friends", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/auth/user/friends", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offline { - local_var_req_builder = - local_var_req_builder.query(&[("offline", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offline { + req_builder = req_builder.query(&[("offline", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::LimitedUserFriend>`"))), + 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<models::LimitedUserFriend>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -236,38 +265,47 @@ pub async fn unfriend( configuration: &configuration::Configuration, user_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/auth/user/friends/{userId}", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::Success`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Success`")))), + } } else { - let local_var_entity: Option = 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } diff --git a/src/apis/groups_api.rs b/src/apis/groups_api.rs index 6c8f167..349453c 100644 --- a/src/apis/groups_api.rs +++ b/src/apis/groups_api.rs @@ -6,10 +6,10 @@ * Generated by: https://openapi-generator.tech */ -use super::{configuration, Error}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; use reqwest; -use serde::{Deserialize, Serialize}; +use serde::{de::Error as _, Deserialize, Serialize}; /// struct for typed errors of method [`add_group_gallery_image`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -421,42 +421,52 @@ pub async fn add_group_gallery_image( group_gallery_id: &str, add_group_gallery_image_request: models::AddGroupGalleryImageRequest, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_group_gallery_id = group_gallery_id; + let p_body_add_group_gallery_image_request = add_group_gallery_image_request; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/galleries/{groupGalleryId}/images", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - groupGalleryId = crate::apis::urlencode(group_gallery_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + groupGalleryId = crate::apis::urlencode(p_path_group_gallery_id) ); - 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()); - } - local_var_req_builder = local_var_req_builder.json(&add_group_gallery_image_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + req_builder = req_builder.json(&p_body_add_group_gallery_image_request); + + 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 `models::GroupGalleryImage`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupGalleryImage`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -467,42 +477,50 @@ pub async fn add_group_member_role( user_id: &str, group_role_id: &str, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_user_id = user_id; + let p_path_group_role_id = group_role_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/members/{userId}/roles/{groupRoleId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - userId = crate::apis::urlencode(user_id), - groupRoleId = crate::apis::urlencode(group_role_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + userId = crate::apis::urlencode(p_path_user_id), + groupRoleId = crate::apis::urlencode(p_path_group_role_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + 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 local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -512,41 +530,50 @@ pub async fn add_group_post( group_id: &str, create_group_post_request: models::CreateGroupPostRequest, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_body_create_group_post_request = create_group_post_request; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/posts", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - 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()); - } - local_var_req_builder = local_var_req_builder.json(&create_group_post_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + req_builder = req_builder.json(&p_body_create_group_post_request); + + 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 `models::GroupPost`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupPost`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -556,41 +583,50 @@ pub async fn ban_group_member( group_id: &str, ban_group_member_request: models::BanGroupMemberRequest, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_body_ban_group_member_request = ban_group_member_request; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/bans", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - 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()); - } - local_var_req_builder = local_var_req_builder.json(&ban_group_member_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + req_builder = req_builder.json(&p_body_ban_group_member_request); + + 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 `models::GroupMember`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupMember`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -599,40 +635,37 @@ pub async fn cancel_group_request( configuration: &configuration::Configuration, group_id: &str, ) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/requests", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -641,37 +674,45 @@ pub async fn create_group( configuration: &configuration::Configuration, create_group_request: models::CreateGroupRequest, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/groups", 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()); - } - local_var_req_builder = local_var_req_builder.json(&create_group_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + // add a prefix to parameters to efficiently prevent name collisions + let p_body_create_group_request = create_group_request; + + let uri_str = format!("{}/groups", 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()); + } + req_builder = req_builder.json(&p_body_create_group_request); + + 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 `models::Group`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Group`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -681,41 +722,50 @@ pub async fn create_group_announcement( group_id: &str, create_group_announcement_request: models::CreateGroupAnnouncementRequest, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_body_create_group_announcement_request = create_group_announcement_request; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/announcement", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - 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()); - } - local_var_req_builder = local_var_req_builder.json(&create_group_announcement_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + req_builder = req_builder.json(&p_body_create_group_announcement_request); + + 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 `models::GroupAnnouncement`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupAnnouncement`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -725,41 +775,50 @@ pub async fn create_group_gallery( group_id: &str, create_group_gallery_request: models::CreateGroupGalleryRequest, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_body_create_group_gallery_request = create_group_gallery_request; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/galleries", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - 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()); - } - local_var_req_builder = local_var_req_builder.json(&create_group_gallery_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + req_builder = req_builder.json(&p_body_create_group_gallery_request); + + 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 `models::GroupGallery`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupGallery`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -769,41 +828,39 @@ pub async fn create_group_invite( group_id: &str, create_group_invite_request: models::CreateGroupInviteRequest, ) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_body_create_group_invite_request = create_group_invite_request; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/invites", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&create_group_invite_request); + req_builder = req_builder.json(&p_body_create_group_invite_request); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -813,41 +870,50 @@ pub async fn create_group_role( group_id: &str, create_group_role_request: models::CreateGroupRoleRequest, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_body_create_group_role_request = create_group_role_request; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/roles", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - 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()); - } - local_var_req_builder = local_var_req_builder.json(&create_group_role_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + req_builder = req_builder.json(&p_body_create_group_role_request); + + 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 `models::GroupRole`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupRole`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -856,40 +922,48 @@ pub async fn delete_group( configuration: &configuration::Configuration, group_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + 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 `models::Success`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Success`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -898,40 +972,48 @@ pub async fn delete_group_announcement( configuration: &configuration::Configuration, group_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/announcement", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + 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 `models::Success`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Success`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -941,41 +1023,50 @@ pub async fn delete_group_gallery( group_id: &str, group_gallery_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_group_gallery_id = group_gallery_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/galleries/{groupGalleryId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - groupGalleryId = crate::apis::urlencode(group_gallery_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + groupGalleryId = crate::apis::urlencode(p_path_group_gallery_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + 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 `models::Success`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Success`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -986,42 +1077,52 @@ pub async fn delete_group_gallery_image( group_gallery_id: &str, group_gallery_image_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_group_gallery_id = group_gallery_id; + let p_path_group_gallery_image_id = group_gallery_image_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/galleries/{groupGalleryId}/images/{groupGalleryImageId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - groupGalleryId = crate::apis::urlencode(group_gallery_id), - groupGalleryImageId = crate::apis::urlencode(group_gallery_image_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + groupGalleryId = crate::apis::urlencode(p_path_group_gallery_id), + groupGalleryImageId = crate::apis::urlencode(p_path_group_gallery_image_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + 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 `models::Success`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Success`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1031,41 +1132,39 @@ pub async fn delete_group_invite( group_id: &str, user_id: &str, ) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_user_id = user_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/invites/{userId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - userId = crate::apis::urlencode(user_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1075,41 +1174,50 @@ pub async fn delete_group_post( group_id: &str, notification_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_notification_id = notification_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/posts/{notificationId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - notificationId = crate::apis::urlencode(notification_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + notificationId = crate::apis::urlencode(p_path_notification_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + 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 `models::Success`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Success`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1119,41 +1227,50 @@ pub async fn delete_group_role( group_id: &str, group_role_id: &str, ) -> Result, Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_group_role_id = group_role_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/roles/{groupRoleId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - groupRoleId = crate::apis::urlencode(group_role_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + groupRoleId = crate::apis::urlencode(p_path_group_role_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + 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<models::GroupRole>`"))), + 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<models::GroupRole>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1163,43 +1280,50 @@ pub async fn get_group( group_id: &str, include_roles: Option, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_query_include_roles = include_roles; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = include_roles { - local_var_req_builder = - local_var_req_builder.query(&[("includeRoles", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_include_roles { + req_builder = req_builder.query(&[("includeRoles", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::Group`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Group`")))), + } } else { - let local_var_entity: Option = 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1208,40 +1332,46 @@ pub async fn get_group_announcements( configuration: &configuration::Configuration, group_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/announcement", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::GroupAnnouncement`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupAnnouncement`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1257,67 +1387,74 @@ pub async fn get_group_audit_logs( event_types: Option<&str>, target_ids: Option<&str>, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_query_n = n; + let p_query_offset = offset; + let p_query_start_date = start_date; + let p_query_end_date = end_date; + let p_query_actor_ids = actor_ids; + let p_query_event_types = event_types; + let p_query_target_ids = target_ids; + + let uri_str = format!( "{}/groups/{groupId}/auditLogs", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = start_date { - local_var_req_builder = - local_var_req_builder.query(&[("startDate", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_start_date { + req_builder = req_builder.query(&[("startDate", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = end_date { - local_var_req_builder = - local_var_req_builder.query(&[("endDate", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_end_date { + req_builder = req_builder.query(&[("endDate", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = actor_ids { - local_var_req_builder = - local_var_req_builder.query(&[("actorIds", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_actor_ids { + req_builder = req_builder.query(&[("actorIds", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = event_types { - local_var_req_builder = - local_var_req_builder.query(&[("eventTypes", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_event_types { + req_builder = req_builder.query(&[("eventTypes", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = target_ids { - local_var_req_builder = - local_var_req_builder.query(&[("targetIds", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_target_ids { + req_builder = req_builder.query(&[("targetIds", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::PaginatedGroupAuditLogEntryList`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PaginatedGroupAuditLogEntryList`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1328,47 +1465,54 @@ pub async fn get_group_bans( n: Option, offset: Option, ) -> Result, Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_query_n = n; + let p_query_offset = offset; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/bans", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::GroupMember>`"))), + 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<models::GroupMember>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1381,52 +1525,60 @@ pub async fn get_group_gallery_images( offset: Option, approved: Option, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_group_gallery_id = group_gallery_id; + let p_query_n = n; + let p_query_offset = offset; + let p_query_approved = approved; + + let uri_str = format!( "{}/groups/{groupId}/galleries/{groupGalleryId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - groupGalleryId = crate::apis::urlencode(group_gallery_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + groupGalleryId = crate::apis::urlencode(p_path_group_gallery_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = approved { - local_var_req_builder = - local_var_req_builder.query(&[("approved", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_approved { + req_builder = req_builder.query(&[("approved", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::GroupGalleryImage>`"))), + 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<models::GroupGalleryImage>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1435,40 +1587,46 @@ pub async fn get_group_instances( configuration: &configuration::Configuration, group_id: &str, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/instances", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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<models::GroupInstance>`"))), + 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<models::GroupInstance>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1479,47 +1637,54 @@ pub async fn get_group_invites( n: Option, offset: Option, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_query_n = n; + let p_query_offset = offset; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/invites", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::GroupMember>`"))), + 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<models::GroupMember>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1529,41 +1694,48 @@ pub async fn get_group_member( group_id: &str, user_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_user_id = user_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/members/{userId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - userId = crate::apis::urlencode(user_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + userId = crate::apis::urlencode(p_path_user_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::GroupLimitedMember`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupLimitedMember`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1576,55 +1748,62 @@ pub async fn get_group_members( sort: Option, role_id: Option<&str>, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_query_n = n; + let p_query_offset = offset; + let p_query_sort = sort; + let p_query_role_id = role_id; + + let uri_str = format!( "{}/groups/{groupId}/members", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = sort { - local_var_req_builder = - local_var_req_builder.query(&[("sort", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_sort { + req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = role_id { - local_var_req_builder = - local_var_req_builder.query(&[("roleId", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_role_id { + req_builder = req_builder.query(&[("roleId", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::GroupMember>`"))), + 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<models::GroupMember>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1633,40 +1812,46 @@ pub async fn get_group_permissions( configuration: &configuration::Configuration, group_id: &str, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/permissions", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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<models::GroupPermission>`"))), + 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<models::GroupPermission>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1678,51 +1863,58 @@ pub async fn get_group_posts( offset: Option, public_only: Option, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_query_n = n; + let p_query_offset = offset; + let p_query_public_only = public_only; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/posts", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = public_only { - local_var_req_builder = - local_var_req_builder.query(&[("publicOnly", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_public_only { + req_builder = req_builder.query(&[("publicOnly", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::GetGroupPosts200Response`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetGroupPosts200Response`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1734,51 +1926,58 @@ pub async fn get_group_requests( offset: Option, blocked: Option, ) -> Result, Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_query_n = n; + let p_query_offset = offset; + let p_query_blocked = blocked; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/requests", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = blocked { - local_var_req_builder = - local_var_req_builder.query(&[("blocked", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_blocked { + req_builder = req_builder.query(&[("blocked", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::GroupMember>`"))), + 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<models::GroupMember>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1789,36 +1988,39 @@ pub async fn get_group_role_templates( std::collections::HashMap, Error, > { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/groups/roleTemplates", 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let uri_str = format!("{}/groups/roleTemplates", 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()); + } + + 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 `std::collections::HashMap<String, models::GroupRoleTemplateValues>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, models::GroupRoleTemplateValues>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1827,40 +2029,46 @@ pub async fn get_group_roles( configuration: &configuration::Configuration, group_id: &str, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/roles", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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<models::GroupRole>`"))), + 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<models::GroupRole>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1869,40 +2077,48 @@ pub async fn join_group( configuration: &configuration::Configuration, group_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/join", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::GroupMember`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupMember`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1912,41 +2128,39 @@ pub async fn kick_group_member( group_id: &str, user_id: &str, ) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_user_id = user_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/members/{userId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - userId = crate::apis::urlencode(user_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1955,40 +2169,37 @@ pub async fn leave_group( configuration: &configuration::Configuration, group_id: &str, ) -> Result<(), Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/leave", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -1999,42 +2210,52 @@ pub async fn remove_group_member_role( user_id: &str, group_role_id: &str, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_user_id = user_id; + let p_path_group_role_id = group_role_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/members/{userId}/roles/{groupRoleId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - userId = crate::apis::urlencode(user_id), - groupRoleId = crate::apis::urlencode(group_role_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + userId = crate::apis::urlencode(p_path_user_id), + groupRoleId = crate::apis::urlencode(p_path_group_role_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + 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 local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -2045,42 +2266,39 @@ pub async fn respond_group_join_request( user_id: &str, respond_group_join_request: models::RespondGroupJoinRequest, ) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_user_id = user_id; + let p_body_respond_group_join_request = respond_group_join_request; - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/requests/{userId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - userId = crate::apis::urlencode(user_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&respond_group_join_request); + req_builder = req_builder.json(&p_body_respond_group_join_request); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -2091,47 +2309,53 @@ pub async fn search_groups( offset: Option, n: Option, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_query = query; + let p_query_offset = offset; + let p_query_n = n; - let local_var_uri_str = format!("{}/groups", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/groups", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = query { - local_var_req_builder = - local_var_req_builder.query(&[("query", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_query { + req_builder = req_builder.query(&[("query", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::LimitedGroup>`"))), + 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<models::LimitedGroup>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -2141,41 +2365,50 @@ pub async fn unban_group_member( group_id: &str, user_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_user_id = user_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/bans/{userId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - userId = crate::apis::urlencode(user_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + userId = crate::apis::urlencode(p_path_user_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + 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 `models::GroupMember`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupMember`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -2185,41 +2418,48 @@ pub async fn update_group( group_id: &str, update_group_request: Option, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_body_update_group_request = update_group_request; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, 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(&update_group_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(&p_body_update_group_request); + + 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 `models::Group`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Group`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -2230,42 +2470,50 @@ pub async fn update_group_gallery( group_gallery_id: &str, update_group_gallery_request: Option, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_group_gallery_id = group_gallery_id; + let p_body_update_group_gallery_request = update_group_gallery_request; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/galleries/{groupGalleryId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - groupGalleryId = crate::apis::urlencode(group_gallery_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + groupGalleryId = crate::apis::urlencode(p_path_group_gallery_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, 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(&update_group_gallery_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(&p_body_update_group_gallery_request); + + 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 `models::GroupGallery`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupGallery`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -2276,42 +2524,50 @@ pub async fn update_group_member( user_id: &str, update_group_member_request: Option, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_user_id = user_id; + let p_body_update_group_member_request = update_group_member_request; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/members/{userId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - userId = crate::apis::urlencode(user_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, 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(&update_group_member_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(&p_body_update_group_member_request); + + 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 `models::GroupLimitedMember`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupLimitedMember`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -2322,42 +2578,50 @@ pub async fn update_group_post( notification_id: &str, create_group_post_request: models::CreateGroupPostRequest, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_notification_id = notification_id; + let p_body_create_group_post_request = create_group_post_request; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/posts/{notificationId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - notificationId = crate::apis::urlencode(notification_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + notificationId = crate::apis::urlencode(p_path_notification_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, 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(&create_group_post_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(&p_body_create_group_post_request); + + 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 `models::GroupPost`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupPost`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -2367,41 +2631,48 @@ pub async fn update_group_representation( group_id: &str, update_group_representation_request: models::UpdateGroupRepresentationRequest, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_body_update_group_representation_request = update_group_representation_request; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/representation", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, 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(&update_group_representation_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(&p_body_update_group_representation_request); + + 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 `models::Success`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Success`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -2412,41 +2683,49 @@ pub async fn update_group_role( group_role_id: &str, update_group_role_request: Option, ) -> Result, Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_group_id = group_id; + let p_path_group_role_id = group_role_id; + let p_body_update_group_role_request = update_group_role_request; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/groups/{groupId}/roles/{groupRoleId}", - local_var_configuration.base_path, - groupId = crate::apis::urlencode(group_id), - groupRoleId = crate::apis::urlencode(group_role_id) + configuration.base_path, + groupId = crate::apis::urlencode(p_path_group_id), + groupRoleId = crate::apis::urlencode(p_path_group_role_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, 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(&update_group_role_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(&p_body_update_group_role_request); + + 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<models::GroupRole>`"))), + 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<models::GroupRole>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } diff --git a/src/apis/instances_api.rs b/src/apis/instances_api.rs index 044f399..de73691 100644 --- a/src/apis/instances_api.rs +++ b/src/apis/instances_api.rs @@ -6,10 +6,10 @@ * Generated by: https://openapi-generator.tech */ -use super::{configuration, Error}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; use reqwest; -use serde::{Deserialize, Serialize}; +use serde::{de::Error as _, Deserialize, Serialize}; /// struct for typed errors of method [`close_instance`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -70,49 +70,58 @@ pub async fn close_instance( hard_close: Option, closed_at: Option, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_world_id = world_id; + let p_path_instance_id = instance_id; + let p_query_hard_close = hard_close; + let p_query_closed_at = closed_at; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/instances/{worldId}:{instanceId}", - local_var_configuration.base_path, - worldId = crate::apis::urlencode(world_id), - instanceId = crate::apis::urlencode(instance_id) + configuration.base_path, + worldId = crate::apis::urlencode(p_path_world_id), + instanceId = crate::apis::urlencode(p_path_instance_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); - if let Some(ref local_var_str) = hard_close { - local_var_req_builder = - local_var_req_builder.query(&[("hardClose", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_hard_close { + req_builder = req_builder.query(&[("hardClose", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = closed_at { - local_var_req_builder = - local_var_req_builder.query(&[("closedAt", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_closed_at { + req_builder = req_builder.query(&[("closedAt", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::Instance`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Instance`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -121,37 +130,45 @@ pub async fn create_instance( configuration: &configuration::Configuration, create_instance_request: models::CreateInstanceRequest, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_body_create_instance_request = create_instance_request; - let local_var_client = &local_var_configuration.client; + let uri_str = format!("{}/instances", configuration.base_path); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); - let local_var_uri_str = format!("{}/instances", 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&create_instance_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + req_builder = req_builder.json(&p_body_create_instance_request); + + 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 `models::Instance`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Instance`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -161,41 +178,48 @@ pub async fn get_instance( world_id: &str, instance_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_world_id = world_id; + let p_path_instance_id = instance_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/instances/{worldId}:{instanceId}", - local_var_configuration.base_path, - worldId = crate::apis::urlencode(world_id), - instanceId = crate::apis::urlencode(instance_id) + configuration.base_path, + worldId = crate::apis::urlencode(p_path_world_id), + instanceId = crate::apis::urlencode(p_path_instance_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::Instance`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Instance`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -204,40 +228,46 @@ pub async fn get_instance_by_short_name( configuration: &configuration::Configuration, short_name: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_short_name = short_name; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/instances/s/{shortName}", - local_var_configuration.base_path, - shortName = crate::apis::urlencode(short_name) + configuration.base_path, + shortName = crate::apis::urlencode(p_path_short_name) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::Instance`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Instance`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -247,43 +277,49 @@ pub async fn get_recent_locations( n: Option, offset: Option, ) -> Result, Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_n = n; + let p_query_offset = offset; - let local_var_client = &local_var_configuration.client; + let uri_str = format!("{}/instances/recent", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_uri_str = format!("{}/instances/recent", 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_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -293,40 +329,47 @@ pub async fn get_short_name( world_id: &str, instance_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_world_id = world_id; + let p_path_instance_id = instance_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/instances/{worldId}:{instanceId}/shortName", - local_var_configuration.base_path, - worldId = crate::apis::urlencode(world_id), - instanceId = crate::apis::urlencode(instance_id) + configuration.base_path, + worldId = crate::apis::urlencode(p_path_world_id), + instanceId = crate::apis::urlencode(p_path_instance_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::InstanceShortNameResponse`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::InstanceShortNameResponse`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } diff --git a/src/apis/inventory_api.rs b/src/apis/inventory_api.rs index a566a95..204994f 100644 --- a/src/apis/inventory_api.rs +++ b/src/apis/inventory_api.rs @@ -6,10 +6,10 @@ * Generated by: https://openapi-generator.tech */ -use super::{configuration, Error}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; use reqwest; -use serde::{Deserialize, Serialize}; +use serde::{de::Error as _, Deserialize, Serialize}; /// struct for typed errors of method [`get_inventory`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -88,71 +88,77 @@ pub async fn get_inventory( not_flags: Option, archived: Option, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/inventory", 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_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + // add a prefix to parameters to efficiently prevent name collisions + let p_query_n = n; + let p_query_offset = offset; + let p_query_order = order; + let p_query_tags = tags; + let p_query_types = types; + let p_query_flags = flags; + let p_query_not_types = not_types; + let p_query_not_flags = not_flags; + let p_query_archived = archived; + + let uri_str = format!("{}/inventory", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = order { - local_var_req_builder = - local_var_req_builder.query(&[("order", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_order { + req_builder = req_builder.query(&[("order", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = tags { - local_var_req_builder = - local_var_req_builder.query(&[("tags", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_tags { + req_builder = req_builder.query(&[("tags", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = types { - local_var_req_builder = - local_var_req_builder.query(&[("types", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_types { + req_builder = req_builder.query(&[("types", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = flags { - local_var_req_builder = - local_var_req_builder.query(&[("flags", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_flags { + req_builder = req_builder.query(&[("flags", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = not_types { - local_var_req_builder = - local_var_req_builder.query(&[("notTypes", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_not_types { + req_builder = req_builder.query(&[("notTypes", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = not_flags { - local_var_req_builder = - local_var_req_builder.query(&[("notFlags", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_not_flags { + req_builder = req_builder.query(&[("notFlags", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = archived { - local_var_req_builder = - local_var_req_builder.query(&[("archived", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_archived { + req_builder = req_builder.query(&[("archived", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::Inventory`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Inventory`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -161,40 +167,45 @@ pub async fn get_inventory_drops( configuration: &configuration::Configuration, active: Option, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_active = active; - let local_var_uri_str = format!("{}/inventory/drops", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/inventory/drops", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = active { - local_var_req_builder = - local_var_req_builder.query(&[("active", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_active { + req_builder = req_builder.query(&[("active", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::InventoryDrop>`"))), + 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<models::InventoryDrop>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -203,40 +214,46 @@ pub async fn get_inventory_template( configuration: &configuration::Configuration, inventory_template_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_inventory_template_id = inventory_template_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/inventory/template/{inventoryTemplateId}", - local_var_configuration.base_path, - inventoryTemplateId = crate::apis::urlencode(inventory_template_id) + configuration.base_path, + inventoryTemplateId = crate::apis::urlencode(p_path_inventory_template_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::InventoryTemplate`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::InventoryTemplate`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -245,40 +262,46 @@ pub async fn get_own_inventory_item( configuration: &configuration::Configuration, inventory_item_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_inventory_item_id = inventory_item_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/inventory/{inventoryItemId}", - local_var_configuration.base_path, - inventoryItemId = crate::apis::urlencode(inventory_item_id) + configuration.base_path, + inventoryItemId = crate::apis::urlencode(p_path_inventory_item_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::InventoryItem`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::InventoryItem`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -289,42 +312,49 @@ pub async fn share_inventory_item_direct( duration: i32, share_inventory_item_direct_request: models::ShareInventoryItemDirectRequest, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/inventory/cloning/direct", - local_var_configuration.base_path - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - local_var_req_builder = local_var_req_builder.query(&[("itemId", &item_id.to_string())]); - local_var_req_builder = local_var_req_builder.query(&[("duration", &duration.to_string())]); - 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()); + // add a prefix to parameters to efficiently prevent name collisions + let p_query_item_id = item_id; + let p_query_duration = duration; + let p_body_share_inventory_item_direct_request = share_inventory_item_direct_request; + + let uri_str = format!("{}/inventory/cloning/direct", configuration.base_path); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); + + req_builder = req_builder.query(&[("itemId", &p_query_item_id.to_string())]); + req_builder = req_builder.query(&[("duration", &p_query_duration.to_string())]); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&share_inventory_item_direct_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + req_builder = req_builder.json(&p_body_share_inventory_item_direct_request); + + 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 `models::OkStatus`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OkStatus`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -334,41 +364,45 @@ pub async fn share_inventory_item_pedestal( item_id: &str, duration: i32, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_item_id = item_id; + let p_query_duration = duration; - let local_var_client = &local_var_configuration.client; + let uri_str = format!("{}/inventory/cloning/pedestal", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_uri_str = format!( - "{}/inventory/cloning/pedestal", - local_var_configuration.base_path - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - local_var_req_builder = local_var_req_builder.query(&[("itemId", &item_id.to_string())]); - local_var_req_builder = local_var_req_builder.query(&[("duration", &duration.to_string())]); - 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()); + req_builder = req_builder.query(&[("itemId", &p_query_item_id.to_string())]); + req_builder = req_builder.query(&[("duration", &p_query_duration.to_string())]); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::InventorySpawn`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::InventorySpawn`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -377,37 +411,43 @@ pub async fn spawn_inventory_item( configuration: &configuration::Configuration, id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_id = id; - let local_var_client = &local_var_configuration.client; + let uri_str = format!("{}/inventory/spawn", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_uri_str = format!("{}/inventory/spawn", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - local_var_req_builder = local_var_req_builder.query(&[("id", &id.to_string())]); - 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()); + req_builder = req_builder.query(&[("id", &p_query_id.to_string())]); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::InventorySpawn`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::InventorySpawn`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -417,40 +457,47 @@ pub async fn update_own_inventory_item( inventory_item_id: &str, update_inventory_item_request: Option, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_inventory_item_id = inventory_item_id; + let p_body_update_inventory_item_request = update_inventory_item_request; - let local_var_uri_str = format!( + let uri_str = format!( "{}/inventory/{inventoryItemId}", - local_var_configuration.base_path, - inventoryItemId = crate::apis::urlencode(inventory_item_id) + configuration.base_path, + inventoryItemId = crate::apis::urlencode(p_path_inventory_item_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&update_inventory_item_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + req_builder = req_builder.json(&p_body_update_inventory_item_request); + + 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 `models::InventoryItem`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::InventoryItem`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } diff --git a/src/apis/invite_api.rs b/src/apis/invite_api.rs index 97be935..e58d46e 100644 --- a/src/apis/invite_api.rs +++ b/src/apis/invite_api.rs @@ -6,10 +6,10 @@ * Generated by: https://openapi-generator.tech */ -use super::{configuration, Error}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; use reqwest; -use serde::{Deserialize, Serialize}; +use serde::{de::Error as _, Deserialize, Serialize}; /// struct for typed errors of method [`get_invite_message`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -115,42 +115,50 @@ pub async fn get_invite_message( message_type: models::InviteMessageType, slot: i32, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + let p_path_message_type = message_type; + let p_path_slot = slot; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/message/{userId}/{messageType}/{slot}", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id), - messageType = message_type.to_string(), - slot = slot + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id), + messageType = p_path_message_type.to_string(), + slot = p_path_slot ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::InviteMessage`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::InviteMessage`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -160,41 +168,48 @@ pub async fn get_invite_messages( user_id: &str, message_type: models::InviteMessageType, ) -> Result, Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + let p_path_message_type = message_type; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/message/{userId}/{messageType}", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id), - messageType = message_type.to_string() + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id), + messageType = p_path_message_type.to_string() ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::InviteMessage>`"))), + 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<models::InviteMessage>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -204,41 +219,50 @@ pub async fn invite_myself_to( world_id: &str, instance_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_world_id = world_id; + let p_path_instance_id = instance_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/invite/myself/to/{worldId}:{instanceId}", - local_var_configuration.base_path, - worldId = crate::apis::urlencode(world_id), - instanceId = crate::apis::urlencode(instance_id) + configuration.base_path, + worldId = crate::apis::urlencode(p_path_world_id), + instanceId = crate::apis::urlencode(p_path_instance_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::SentNotification`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SentNotification`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -248,41 +272,50 @@ pub async fn invite_user( user_id: &str, invite_request: models::InviteRequest, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + let p_body_invite_request = invite_request; - let local_var_uri_str = format!( + let uri_str = format!( "{}/invite/{userId}", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&invite_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + req_builder = req_builder.json(&p_body_invite_request); + + 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 `models::SentNotification`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SentNotification`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -293,44 +326,54 @@ pub async fn invite_user_with_photo( image: std::path::PathBuf, data: models::InviteRequest, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + let p_form_image = image; + let p_form_data = data; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/invite/{userId}/photo", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let mut local_var_form = reqwest::multipart::Form::new(); + let mut multipart_form = reqwest::multipart::Form::new(); // TODO: support file upload for 'image' parameter - local_var_form = local_var_form.text("data", serde_json::to_string_pretty(&data)?); - local_var_req_builder = local_var_req_builder.multipart(local_var_form); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + multipart_form = multipart_form.text("data", serde_json::to_string_pretty(&p_form_data)?); + req_builder = req_builder.multipart(multipart_form); + + 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 `models::SentNotification`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SentNotification`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -340,41 +383,50 @@ pub async fn request_invite( user_id: &str, request_invite_request: Option, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + let p_body_request_invite_request = request_invite_request; - let local_var_uri_str = format!( + let uri_str = format!( "{}/requestInvite/{userId}", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&request_invite_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + req_builder = req_builder.json(&p_body_request_invite_request); + + 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 `models::Notification`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Notification`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -385,44 +437,54 @@ pub async fn request_invite_with_photo( image: std::path::PathBuf, data: models::RequestInviteRequest, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + let p_form_image = image; + let p_form_data = data; - let local_var_uri_str = format!( + let uri_str = format!( "{}/requestInvite/{userId}/photo", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let mut local_var_form = reqwest::multipart::Form::new(); + let mut multipart_form = reqwest::multipart::Form::new(); // TODO: support file upload for 'image' parameter - local_var_form = local_var_form.text("data", serde_json::to_string_pretty(&data)?); - local_var_req_builder = local_var_req_builder.multipart(local_var_form); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + multipart_form = multipart_form.text("data", serde_json::to_string_pretty(&p_form_data)?); + req_builder = req_builder.multipart(multipart_form); + + 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 `models::Notification`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Notification`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -433,42 +495,52 @@ pub async fn reset_invite_message( message_type: models::InviteMessageType, slot: i32, ) -> Result, Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + let p_path_message_type = message_type; + let p_path_slot = slot; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/message/{userId}/{messageType}/{slot}", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id), - messageType = message_type.to_string(), - slot = slot + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id), + messageType = p_path_message_type.to_string(), + slot = p_path_slot ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::InviteMessage>`"))), + 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<models::InviteMessage>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -478,41 +550,50 @@ pub async fn respond_invite( notification_id: &str, invite_response: models::InviteResponse, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_notification_id = notification_id; + let p_body_invite_response = invite_response; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/invite/{notificationId}/response", - local_var_configuration.base_path, - notificationId = crate::apis::urlencode(notification_id) + configuration.base_path, + notificationId = crate::apis::urlencode(p_path_notification_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&invite_response); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + req_builder = req_builder.json(&p_body_invite_response); + + 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 `models::Notification`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Notification`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -523,44 +604,54 @@ pub async fn respond_invite_with_photo( image: std::path::PathBuf, data: models::InviteResponse, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_notification_id = notification_id; + let p_form_image = image; + let p_form_data = data; - let local_var_uri_str = format!( + let uri_str = format!( "{}/invite/{notificationId}/response/photo", - local_var_configuration.base_path, - notificationId = crate::apis::urlencode(notification_id) + configuration.base_path, + notificationId = crate::apis::urlencode(p_path_notification_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let mut local_var_form = reqwest::multipart::Form::new(); + let mut multipart_form = reqwest::multipart::Form::new(); // TODO: support file upload for 'image' parameter - local_var_form = local_var_form.text("data", serde_json::to_string_pretty(&data)?); - local_var_req_builder = local_var_req_builder.multipart(local_var_form); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + multipart_form = multipart_form.text("data", serde_json::to_string_pretty(&p_form_data)?); + req_builder = req_builder.multipart(multipart_form); + + 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 `models::Notification`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Notification`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -572,42 +663,51 @@ pub async fn update_invite_message( slot: i32, update_invite_message_request: Option, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + let p_path_message_type = message_type; + let p_path_slot = slot; + let p_body_update_invite_message_request = update_invite_message_request; - let local_var_uri_str = format!( + let uri_str = format!( "{}/message/{userId}/{messageType}/{slot}", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id), - messageType = message_type.to_string(), - slot = slot + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id), + messageType = p_path_message_type.to_string(), + slot = p_path_slot ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&update_invite_message_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + req_builder = req_builder.json(&p_body_update_invite_message_request); + + 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<models::InviteMessage>`"))), + 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<models::InviteMessage>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } diff --git a/src/apis/jams_api.rs b/src/apis/jams_api.rs index a6f70e8..aee65dc 100644 --- a/src/apis/jams_api.rs +++ b/src/apis/jams_api.rs @@ -6,10 +6,10 @@ * Generated by: https://openapi-generator.tech */ -use super::{configuration, Error}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; use reqwest; -use serde::{Deserialize, Serialize}; +use serde::{de::Error as _, Deserialize, Serialize}; /// struct for typed errors of method [`get_jam`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -39,39 +39,46 @@ pub async fn get_jam( configuration: &configuration::Configuration, jam_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_jam_id = jam_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/jams/{jamId}", - local_var_configuration.base_path, - jamId = crate::apis::urlencode(jam_id) + configuration.base_path, + jamId = crate::apis::urlencode(p_path_jam_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::Jam`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Jam`")))), + } } else { - let local_var_entity: Option = 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -80,40 +87,46 @@ pub async fn get_jam_submissions( configuration: &configuration::Configuration, jam_id: &str, ) -> Result, Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_jam_id = jam_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/jams/{jamId}/submissions", - local_var_configuration.base_path, - jamId = crate::apis::urlencode(jam_id) + configuration.base_path, + jamId = crate::apis::urlencode(p_path_jam_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::Submission>`"))), + 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<models::Submission>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -122,38 +135,44 @@ pub async fn get_jams( configuration: &configuration::Configuration, r#type: Option<&str>, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_type = r#type; - let local_var_uri_str = format!("{}/jams", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/jams", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = r#type { - local_var_req_builder = - local_var_req_builder.query(&[("type", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_type { + req_builder = req_builder.query(&[("type", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::Jam>`"))), + 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<models::Jam>`")))), + } } else { - let local_var_entity: Option = 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } diff --git a/src/apis/miscellaneous_api.rs b/src/apis/miscellaneous_api.rs index eb26499..db54a8e 100644 --- a/src/apis/miscellaneous_api.rs +++ b/src/apis/miscellaneous_api.rs @@ -6,10 +6,10 @@ * Generated by: https://openapi-generator.tech */ -use super::{configuration, Error}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; use reqwest; -use serde::{Deserialize, Serialize}; +use serde::{de::Error as _, Deserialize, Serialize}; /// struct for typed errors of method [`get_assigned_permissions`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -82,36 +82,39 @@ pub enum GetSystemTimeError { pub async fn get_assigned_permissions( configuration: &configuration::Configuration, ) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/auth/permissions", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/auth/permissions", 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::Permission>`"))), + 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<models::Permission>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -119,36 +122,39 @@ pub async fn get_assigned_permissions( pub async fn get_config( configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/config", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/config", 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::ApiConfig`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ApiConfig`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -158,43 +164,49 @@ pub async fn get_css( variant: Option<&str>, branch: Option<&str>, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_variant = variant; + let p_query_branch = branch; - let local_var_client = &local_var_configuration.client; + let uri_str = format!("{}/css/app.css", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_uri_str = format!("{}/css/app.css", 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_str) = variant { - local_var_req_builder = - local_var_req_builder.query(&[("variant", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_variant { + req_builder = req_builder.query(&[("variant", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = branch { - local_var_req_builder = - local_var_req_builder.query(&[("branch", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_branch { + req_builder = req_builder.query(&[("branch", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `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 `String`")))), + } } else { - let local_var_entity: Option = 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -202,73 +214,80 @@ pub async fn get_css( pub async fn get_current_online_users( configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + let uri_str = format!("{}/visits", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_uri_str = format!("{}/visits", 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `i32`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `i32`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } /// ~~Gets the overall health status, the server name, and the current build version tag of the API.~~ **DEPRECATED:** VRChat has suddenly restricted this endpoint for unknown reasons, and now always return 401 Unauthorized. +#[deprecated] pub async fn get_health( configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + let uri_str = format!("{}/health", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_uri_str = format!("{}/health", 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::ApiHealth`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ApiHealth`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -278,44 +297,49 @@ pub async fn get_info_push( require: Option<&str>, include: Option<&str>, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_require = require; + let p_query_include = include; - let local_var_uri_str = format!("{}/infoPush", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/infoPush", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = require { - local_var_req_builder = - local_var_req_builder.query(&[("require", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_require { + req_builder = req_builder.query(&[("require", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = include { - local_var_req_builder = - local_var_req_builder.query(&[("include", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_include { + req_builder = req_builder.query(&[("include", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::InfoPush>`"))), + 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<models::InfoPush>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -325,44 +349,49 @@ pub async fn get_java_script( variant: Option<&str>, branch: Option<&str>, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_variant = variant; + let p_query_branch = branch; - let local_var_client = &local_var_configuration.client; + let uri_str = format!("{}/js/app.js", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_uri_str = format!("{}/js/app.js", 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_str) = variant { - local_var_req_builder = - local_var_req_builder.query(&[("variant", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_variant { + req_builder = req_builder.query(&[("variant", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = branch { - local_var_req_builder = - local_var_req_builder.query(&[("branch", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_branch { + req_builder = req_builder.query(&[("branch", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `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 `String`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -371,40 +400,46 @@ pub async fn get_permission( configuration: &configuration::Configuration, permission_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_permission_id = permission_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/permissions/{permissionId}", - local_var_configuration.base_path, - permissionId = crate::apis::urlencode(permission_id) + configuration.base_path, + permissionId = crate::apis::urlencode(p_path_permission_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::Permission`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Permission`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -412,35 +447,38 @@ pub async fn get_permission( pub async fn get_system_time( configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/time", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/time", 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `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 `String`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } diff --git a/src/apis/mod.rs b/src/apis/mod.rs index 94a919a..23faf1a 100644 --- a/src/apis/mod.rs +++ b/src/apis/mod.rs @@ -92,6 +92,27 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String unimplemented!("Only objects are supported with style=deepObject") } +/// Internal use only +/// A content type supported by this client. +#[allow(dead_code)] +enum ContentType { + Json, + Text, + Unsupported(String), +} + +impl From<&str> for ContentType { + fn from(content_type: &str) -> Self { + if content_type.starts_with("application") && content_type.contains("json") { + return Self::Json; + } else if content_type.starts_with("text/plain") { + return Self::Text; + } else { + return Self::Unsupported(content_type.to_string()); + } + } +} + pub mod authentication_api; pub mod avatars_api; pub mod calendar_api; diff --git a/src/apis/notifications_api.rs b/src/apis/notifications_api.rs index 5b9c041..0081c79 100644 --- a/src/apis/notifications_api.rs +++ b/src/apis/notifications_api.rs @@ -6,10 +6,10 @@ * Generated by: https://openapi-generator.tech */ -use super::{configuration, Error}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; use reqwest; -use serde::{Deserialize, Serialize}; +use serde::{de::Error as _, Deserialize, Serialize}; /// struct for typed errors of method [`accept_friend_request`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -66,40 +66,46 @@ pub async fn accept_friend_request( configuration: &configuration::Configuration, notification_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_notification_id = notification_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/auth/user/notifications/{notificationId}/accept", - local_var_configuration.base_path, - notificationId = crate::apis::urlencode(notification_id) + configuration.base_path, + notificationId = crate::apis::urlencode(p_path_notification_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::Success`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Success`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -107,39 +113,39 @@ pub async fn accept_friend_request( pub async fn clear_notifications( configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/auth/user/notifications/clear", - local_var_configuration.base_path - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let uri_str = format!("{}/auth/user/notifications/clear", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::Success`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Success`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -148,40 +154,46 @@ pub async fn delete_notification( configuration: &configuration::Configuration, notification_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_notification_id = notification_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/auth/user/notifications/{notificationId}/hide", - local_var_configuration.base_path, - notificationId = crate::apis::urlencode(notification_id) + configuration.base_path, + notificationId = crate::apis::urlencode(p_path_notification_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::Notification`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Notification`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -190,40 +202,46 @@ pub async fn get_notification( configuration: &configuration::Configuration, notification_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_notification_id = notification_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/auth/user/notifications/{notificationId}", - local_var_configuration.base_path, - notificationId = crate::apis::urlencode(notification_id) + configuration.base_path, + notificationId = crate::apis::urlencode(p_path_notification_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::Notification`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Notification`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -237,62 +255,65 @@ pub async fn get_notifications( n: Option, offset: Option, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/auth/user/notifications", - 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_str) = r#type { - local_var_req_builder = - local_var_req_builder.query(&[("type", &local_var_str.to_string())]); + // add a prefix to parameters to efficiently prevent name collisions + let p_query_type = r#type; + let p_query_sent = sent; + let p_query_hidden = hidden; + let p_query_after = after; + let p_query_n = n; + let p_query_offset = offset; + + let uri_str = format!("{}/auth/user/notifications", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_query_type { + req_builder = req_builder.query(&[("type", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = sent { - local_var_req_builder = - local_var_req_builder.query(&[("sent", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_sent { + req_builder = req_builder.query(&[("sent", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = hidden { - local_var_req_builder = - local_var_req_builder.query(&[("hidden", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_hidden { + req_builder = req_builder.query(&[("hidden", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = after { - local_var_req_builder = - local_var_req_builder.query(&[("after", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_after { + req_builder = req_builder.query(&[("after", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::Notification>`"))), + 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<models::Notification>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -301,39 +322,45 @@ pub async fn mark_notification_as_read( configuration: &configuration::Configuration, notification_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_notification_id = notification_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/auth/user/notifications/{notificationId}/see", - local_var_configuration.base_path, - notificationId = crate::apis::urlencode(notification_id) + configuration.base_path, + notificationId = crate::apis::urlencode(p_path_notification_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::Notification`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Notification`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } diff --git a/src/apis/playermoderation_api.rs b/src/apis/playermoderation_api.rs index 0653599..e291351 100644 --- a/src/apis/playermoderation_api.rs +++ b/src/apis/playermoderation_api.rs @@ -6,10 +6,10 @@ * Generated by: https://openapi-generator.tech */ -use super::{configuration, Error}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; use reqwest; -use serde::{Deserialize, Serialize}; +use serde::{de::Error as _, Deserialize, Serialize}; /// struct for typed errors of method [`clear_all_player_moderations`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -47,39 +47,41 @@ pub enum UnmoderateUserError { pub async fn clear_all_player_moderations( configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/auth/user/playermoderations", configuration.base_path); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/auth/user/playermoderations", - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::Success`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Success`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -90,51 +92,53 @@ pub async fn get_player_moderations( source_user_id: Option<&str>, target_user_id: Option<&str>, ) -> Result, Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_type = r#type; + let p_query_source_user_id = source_user_id; + let p_query_target_user_id = target_user_id; - let local_var_client = &local_var_configuration.client; + let uri_str = format!("{}/auth/user/playermoderations", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_uri_str = format!( - "{}/auth/user/playermoderations", - 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_str) = r#type { - local_var_req_builder = - local_var_req_builder.query(&[("type", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_type { + req_builder = req_builder.query(&[("type", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = source_user_id { - local_var_req_builder = - local_var_req_builder.query(&[("sourceUserId", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_source_user_id { + req_builder = req_builder.query(&[("sourceUserId", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = target_user_id { - local_var_req_builder = - local_var_req_builder.query(&[("targetUserId", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_target_user_id { + req_builder = req_builder.query(&[("targetUserId", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::PlayerModeration>`"))), + 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<models::PlayerModeration>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -143,40 +147,45 @@ pub async fn moderate_user( configuration: &configuration::Configuration, moderate_user_request: models::ModerateUserRequest, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_body_moderate_user_request = moderate_user_request; - let local_var_uri_str = format!( - "{}/auth/user/playermoderations", - local_var_configuration.base_path - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/auth/user/playermoderations", configuration.base_path); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&moderate_user_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + req_builder = req_builder.json(&p_body_moderate_user_request); + + 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 `models::PlayerModeration`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PlayerModeration`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -185,39 +194,42 @@ pub async fn unmoderate_user( configuration: &configuration::Configuration, moderate_user_request: models::ModerateUserRequest, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_body_moderate_user_request = moderate_user_request; - let local_var_uri_str = format!( - "{}/auth/user/unplayermoderate", - local_var_configuration.base_path - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let uri_str = format!("{}/auth/user/unplayermoderate", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&moderate_user_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + req_builder = req_builder.json(&p_body_moderate_user_request); + + 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 `models::Success`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Success`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } diff --git a/src/apis/prints_api.rs b/src/apis/prints_api.rs index 08db88e..5af18f7 100644 --- a/src/apis/prints_api.rs +++ b/src/apis/prints_api.rs @@ -6,10 +6,10 @@ * Generated by: https://openapi-generator.tech */ -use super::{configuration, Error}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; use reqwest; -use serde::{Deserialize, Serialize}; +use serde::{de::Error as _, Deserialize, Serialize}; /// struct for typed errors of method [`delete_print`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -57,40 +57,37 @@ pub async fn delete_print( configuration: &configuration::Configuration, print_id: &str, ) -> Result<(), Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_print_id = print_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/prints/{printId}", - local_var_configuration.base_path, - printId = crate::apis::urlencode(print_id) + configuration.base_path, + printId = crate::apis::urlencode(p_path_print_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -101,46 +98,56 @@ pub async fn edit_print( image: std::path::PathBuf, note: Option<&str>, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_print_id = print_id; + let p_form_image = image; + let p_form_note = note; - let local_var_uri_str = format!( + let uri_str = format!( "{}/prints/{printId}", - local_var_configuration.base_path, - printId = crate::apis::urlencode(print_id) + configuration.base_path, + printId = crate::apis::urlencode(p_path_print_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let mut local_var_form = reqwest::multipart::Form::new(); + let mut multipart_form = reqwest::multipart::Form::new(); // TODO: support file upload for 'image' parameter - if let Some(local_var_param_value) = note { - local_var_form = local_var_form.text("note", local_var_param_value.to_string()); + if let Some(param_value) = p_form_note { + multipart_form = multipart_form.text("note", param_value.to_string()); } - local_var_req_builder = local_var_req_builder.multipart(local_var_form); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + req_builder = req_builder.multipart(multipart_form); + + 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 `models::Print`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Print`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -149,39 +156,46 @@ pub async fn get_print( configuration: &configuration::Configuration, print_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_print_id = print_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/prints/{printId}", - local_var_configuration.base_path, - printId = crate::apis::urlencode(print_id) + configuration.base_path, + printId = crate::apis::urlencode(p_path_print_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::Print`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Print`")))), + } } else { - let local_var_entity: Option = 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -190,40 +204,46 @@ pub async fn get_user_prints( configuration: &configuration::Configuration, user_id: &str, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/prints/user/{userId}", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::Print>`"))), + 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<models::Print>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -236,48 +256,60 @@ pub async fn upload_print( world_id: Option<&str>, world_name: Option<&str>, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/prints", 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()); + // add a prefix to parameters to efficiently prevent name collisions + let p_form_image = image; + let p_form_timestamp = timestamp; + let p_form_note = note; + let p_form_world_id = world_id; + let p_form_world_name = world_name; + + let uri_str = format!("{}/prints", 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()); } - let mut local_var_form = reqwest::multipart::Form::new(); + let mut multipart_form = reqwest::multipart::Form::new(); // TODO: support file upload for 'image' parameter - local_var_form = local_var_form.text("timestamp", timestamp.to_string()); - if let Some(local_var_param_value) = note { - local_var_form = local_var_form.text("note", local_var_param_value.to_string()); + multipart_form = multipart_form.text("timestamp", p_form_timestamp.to_string()); + if let Some(param_value) = p_form_note { + multipart_form = multipart_form.text("note", param_value.to_string()); } - if let Some(local_var_param_value) = world_id { - local_var_form = local_var_form.text("worldId", local_var_param_value.to_string()); + if let Some(param_value) = p_form_world_id { + multipart_form = multipart_form.text("worldId", param_value.to_string()); } - if let Some(local_var_param_value) = world_name { - local_var_form = local_var_form.text("worldName", local_var_param_value.to_string()); + if let Some(param_value) = p_form_world_name { + multipart_form = multipart_form.text("worldName", param_value.to_string()); } - local_var_req_builder = local_var_req_builder.multipart(local_var_form); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + req_builder = req_builder.multipart(multipart_form); + + 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 `models::Print`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Print`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } diff --git a/src/apis/props_api.rs b/src/apis/props_api.rs index 7668110..d09057c 100644 --- a/src/apis/props_api.rs +++ b/src/apis/props_api.rs @@ -6,10 +6,10 @@ * Generated by: https://openapi-generator.tech */ -use super::{configuration, Error}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; use reqwest; -use serde::{Deserialize, Serialize}; +use serde::{de::Error as _, Deserialize, Serialize}; /// struct for typed errors of method [`get_prop`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -24,38 +24,45 @@ pub async fn get_prop( configuration: &configuration::Configuration, prop_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_prop_id = prop_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/props/{propId}", - local_var_configuration.base_path, - propId = crate::apis::urlencode(prop_id) + configuration.base_path, + propId = crate::apis::urlencode(p_path_prop_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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 `models::Prop`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Prop`")))), + } } else { - let local_var_entity: Option = 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } diff --git a/src/apis/users_api.rs b/src/apis/users_api.rs index 6215534..908e3a5 100644 --- a/src/apis/users_api.rs +++ b/src/apis/users_api.rs @@ -6,10 +6,10 @@ * Generated by: https://openapi-generator.tech */ -use super::{configuration, Error}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; use reqwest; -use serde::{Deserialize, Serialize}; +use serde::{de::Error as _, Deserialize, Serialize}; /// struct for typed errors of method [`add_tags`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -162,40 +162,50 @@ pub async fn add_tags( user_id: &str, change_user_tags_request: models::ChangeUserTagsRequest, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + let p_body_change_user_tags_request = change_user_tags_request; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/users/{userId}/addTags", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - 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()); - } - local_var_req_builder = local_var_req_builder.json(&change_user_tags_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + req_builder = req_builder.json(&p_body_change_user_tags_request); + + 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 `models::CurrentUser`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CurrentUser`")))), + } } else { - let local_var_entity: Option = 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -205,41 +215,37 @@ pub async fn check_user_persistence_exists( user_id: &str, world_id: &str, ) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + let p_path_world_id = world_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/users/{userId}/{worldId}/persist/exists", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id), - worldId = crate::apis::urlencode(world_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id), + worldId = crate::apis::urlencode(p_path_world_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -249,41 +255,39 @@ pub async fn delete_user_persistence( user_id: &str, world_id: &str, ) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + let p_path_world_id = world_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/users/{userId}/{worldId}/persist", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id), - worldId = crate::apis::urlencode(world_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id), + worldId = crate::apis::urlencode(p_path_world_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -292,85 +296,100 @@ pub async fn get_user( configuration: &configuration::Configuration, user_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/users/{userId}", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::User`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::User`")))), + } } else { - let local_var_entity: Option = 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } /// ~~Get public user information about a specific user using their name.~~ **DEPRECATED:** VRChat API no longer return usernames of other users. [See issue by Tupper for more information](https://github.com/pypy-vrc/VRCX/issues/429). This endpoint now require Admin Credentials. +#[deprecated] pub async fn get_user_by_name( configuration: &configuration::Configuration, username: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_username = username; - let local_var_uri_str = format!( + let uri_str = format!( "{}/users/{username}/name", - local_var_configuration.base_path, - username = crate::apis::urlencode(username) + configuration.base_path, + username = crate::apis::urlencode(p_path_username) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::User`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::User`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } /// Get user's submitted feedback +#[deprecated] pub async fn get_user_feedback( configuration: &configuration::Configuration, user_id: &str, @@ -378,51 +397,58 @@ pub async fn get_user_feedback( n: Option, offset: Option, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + let p_query_content_id = content_id; + let p_query_n = n; + let p_query_offset = offset; - let local_var_uri_str = format!( + let uri_str = format!( "{}/users/{userId}/feedback", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = content_id { - local_var_req_builder = - local_var_req_builder.query(&[("contentId", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_content_id { + req_builder = req_builder.query(&[("contentId", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::Feedback>`"))), + 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<models::Feedback>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -431,40 +457,46 @@ pub async fn get_user_group_instances( configuration: &configuration::Configuration, user_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/users/{userId}/instances/groups", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::GetUserGroupInstances200Response`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetUserGroupInstances200Response`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -473,40 +505,46 @@ pub async fn get_user_group_requests( configuration: &configuration::Configuration, user_id: &str, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/users/{userId}/groups/requested", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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<models::Group>`"))), + 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<models::Group>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -515,40 +553,46 @@ pub async fn get_user_groups( configuration: &configuration::Configuration, user_id: &str, ) -> Result, Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/users/{userId}/groups", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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<models::LimitedUserGroups>`"))), + 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<models::LimitedUserGroups>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -557,40 +601,46 @@ pub async fn get_user_note( configuration: &configuration::Configuration, user_note_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_note_id = user_note_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/userNotes/{userNoteId}", - local_var_configuration.base_path, - userNoteId = crate::apis::urlencode(user_note_id) + configuration.base_path, + userNoteId = crate::apis::urlencode(p_path_user_note_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::UserNote`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UserNote`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -600,43 +650,49 @@ pub async fn get_user_notes( n: Option, offset: Option, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_n = n; + let p_query_offset = offset; - let local_var_uri_str = format!("{}/userNotes", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/userNotes", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::UserNote>`"))), + 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<models::UserNote>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -645,40 +701,46 @@ pub async fn get_user_represented_group( configuration: &configuration::Configuration, user_id: &str, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/users/{userId}/groups/represented", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::RepresentedGroup`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RepresentedGroup`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -688,41 +750,50 @@ pub async fn remove_tags( user_id: &str, change_user_tags_request: models::ChangeUserTagsRequest, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + let p_body_change_user_tags_request = change_user_tags_request; - let local_var_uri_str = format!( + let uri_str = format!( "{}/users/{userId}/removeTags", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - 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()); - } - local_var_req_builder = local_var_req_builder.json(&change_user_tags_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + req_builder = req_builder.json(&p_body_change_user_tags_request); + + 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 `models::CurrentUser`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CurrentUser`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -734,51 +805,57 @@ pub async fn search_users( n: Option, offset: Option, ) -> Result, Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_search = search; + let p_query_developer_type = developer_type; + let p_query_n = n; + let p_query_offset = offset; - let local_var_client = &local_var_configuration.client; + let uri_str = format!("{}/users", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - 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_str) = search { - local_var_req_builder = - local_var_req_builder.query(&[("search", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_search { + req_builder = req_builder.query(&[("search", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = developer_type { - local_var_req_builder = - local_var_req_builder.query(&[("developerType", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_developer_type { + req_builder = req_builder.query(&[("developerType", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::LimitedUserSearch>`"))), + 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<models::LimitedUserSearch>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -789,42 +866,39 @@ pub async fn update_badge( badge_id: &str, update_user_badge_request: models::UpdateUserBadgeRequest, ) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + let p_path_badge_id = badge_id; + let p_body_update_user_badge_request = update_user_badge_request; - let local_var_uri_str = format!( + let uri_str = format!( "{}/users/{userId}/badges/{badgeId}", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id), - badgeId = crate::apis::urlencode(badge_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id), + badgeId = crate::apis::urlencode(p_path_badge_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&update_user_badge_request); + req_builder = req_builder.json(&p_body_update_user_badge_request); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -834,41 +908,48 @@ pub async fn update_user( user_id: &str, update_user_request: Option, ) -> Result> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + let p_body_update_user_request = update_user_request; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/users/{userId}", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, 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(&update_user_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(&p_body_update_user_request); + + 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 `models::CurrentUser`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CurrentUser`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -877,36 +958,44 @@ pub async fn update_user_note( configuration: &configuration::Configuration, update_user_note_request: models::UpdateUserNoteRequest, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/userNotes", 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()); - } - local_var_req_builder = local_var_req_builder.json(&update_user_note_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + // add a prefix to parameters to efficiently prevent name collisions + let p_body_update_user_note_request = update_user_note_request; + + let uri_str = format!("{}/userNotes", 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()); + } + req_builder = req_builder.json(&p_body_update_user_note_request); + + 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 `models::UserNote`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UserNote`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } diff --git a/src/apis/worlds_api.rs b/src/apis/worlds_api.rs index 0632b1b..e32154c 100644 --- a/src/apis/worlds_api.rs +++ b/src/apis/worlds_api.rs @@ -6,10 +6,10 @@ * Generated by: https://openapi-generator.tech */ -use super::{configuration, Error}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; use reqwest; -use serde::{Deserialize, Serialize}; +use serde::{de::Error as _, Deserialize, Serialize}; /// struct for typed errors of method [`check_user_persistence_exists`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -147,41 +147,37 @@ pub async fn check_user_persistence_exists( user_id: &str, world_id: &str, ) -> Result<(), Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + let p_path_world_id = world_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/users/{userId}/{worldId}/persist/exists", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id), - worldId = crate::apis::urlencode(world_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id), + worldId = crate::apis::urlencode(p_path_world_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -190,37 +186,45 @@ pub async fn create_world( configuration: &configuration::Configuration, create_world_request: Option, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/worlds", 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()); - } - local_var_req_builder = local_var_req_builder.json(&create_world_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + // add a prefix to parameters to efficiently prevent name collisions + let p_body_create_world_request = create_world_request; + + let uri_str = format!("{}/worlds", 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()); + } + req_builder = req_builder.json(&p_body_create_world_request); + + 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 `models::World`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::World`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -230,41 +234,39 @@ pub async fn delete_user_persistence( user_id: &str, world_id: &str, ) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + let p_path_world_id = world_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/users/{userId}/{worldId}/persist", - local_var_configuration.base_path, - userId = crate::apis::urlencode(user_id), - worldId = crate::apis::urlencode(world_id) + configuration.base_path, + userId = crate::apis::urlencode(p_path_user_id), + worldId = crate::apis::urlencode(p_path_world_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -273,40 +275,37 @@ pub async fn delete_world( configuration: &configuration::Configuration, world_id: &str, ) -> Result<(), Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_world_id = world_id; - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( + let uri_str = format!( "{}/worlds/{worldId}", - local_var_configuration.base_path, - worldId = crate::apis::urlencode(world_id) + configuration.base_path, + worldId = crate::apis::urlencode(p_path_world_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -326,82 +325,89 @@ pub async fn get_active_worlds( min_unity_version: Option<&str>, platform: Option<&str>, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_featured = featured; + let p_query_sort = sort; + let p_query_n = n; + let p_query_order = order; + let p_query_offset = offset; + let p_query_search = search; + let p_query_tag = tag; + let p_query_notag = notag; + let p_query_release_status = release_status; + let p_query_max_unity_version = max_unity_version; + let p_query_min_unity_version = min_unity_version; + let p_query_platform = platform; - let local_var_uri_str = format!("{}/worlds/active", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/worlds/active", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = featured { - local_var_req_builder = - local_var_req_builder.query(&[("featured", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_featured { + req_builder = req_builder.query(&[("featured", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = sort { - local_var_req_builder = - local_var_req_builder.query(&[("sort", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_sort { + req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = order { - local_var_req_builder = - local_var_req_builder.query(&[("order", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_order { + req_builder = req_builder.query(&[("order", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = search { - local_var_req_builder = - local_var_req_builder.query(&[("search", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_search { + req_builder = req_builder.query(&[("search", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = tag { - local_var_req_builder = local_var_req_builder.query(&[("tag", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_tag { + req_builder = req_builder.query(&[("tag", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = notag { - local_var_req_builder = - local_var_req_builder.query(&[("notag", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_notag { + req_builder = req_builder.query(&[("notag", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = release_status { - local_var_req_builder = - local_var_req_builder.query(&[("releaseStatus", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_release_status { + req_builder = req_builder.query(&[("releaseStatus", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = max_unity_version { - local_var_req_builder = - local_var_req_builder.query(&[("maxUnityVersion", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_max_unity_version { + req_builder = req_builder.query(&[("maxUnityVersion", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = min_unity_version { - local_var_req_builder = - local_var_req_builder.query(&[("minUnityVersion", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_min_unity_version { + req_builder = req_builder.query(&[("minUnityVersion", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = platform { - local_var_req_builder = - local_var_req_builder.query(&[("platform", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_platform { + req_builder = req_builder.query(&[("platform", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::LimitedWorld>`"))), + 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<models::LimitedWorld>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -422,86 +428,93 @@ pub async fn get_favorited_worlds( platform: Option<&str>, user_id: Option<&str>, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_featured = featured; + let p_query_sort = sort; + let p_query_n = n; + let p_query_order = order; + let p_query_offset = offset; + let p_query_search = search; + let p_query_tag = tag; + let p_query_notag = notag; + let p_query_release_status = release_status; + let p_query_max_unity_version = max_unity_version; + let p_query_min_unity_version = min_unity_version; + let p_query_platform = platform; + let p_query_user_id = user_id; - let local_var_uri_str = format!("{}/worlds/favorites", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/worlds/favorites", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_str) = featured { - local_var_req_builder = - local_var_req_builder.query(&[("featured", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_featured { + req_builder = req_builder.query(&[("featured", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = sort { - local_var_req_builder = - local_var_req_builder.query(&[("sort", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_sort { + req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = order { - local_var_req_builder = - local_var_req_builder.query(&[("order", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_order { + req_builder = req_builder.query(&[("order", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = search { - local_var_req_builder = - local_var_req_builder.query(&[("search", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_search { + req_builder = req_builder.query(&[("search", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = tag { - local_var_req_builder = local_var_req_builder.query(&[("tag", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_tag { + req_builder = req_builder.query(&[("tag", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = notag { - local_var_req_builder = - local_var_req_builder.query(&[("notag", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_notag { + req_builder = req_builder.query(&[("notag", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = release_status { - local_var_req_builder = - local_var_req_builder.query(&[("releaseStatus", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_release_status { + req_builder = req_builder.query(&[("releaseStatus", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = max_unity_version { - local_var_req_builder = - local_var_req_builder.query(&[("maxUnityVersion", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_max_unity_version { + req_builder = req_builder.query(&[("maxUnityVersion", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = min_unity_version { - local_var_req_builder = - local_var_req_builder.query(&[("minUnityVersion", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_min_unity_version { + req_builder = req_builder.query(&[("minUnityVersion", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = platform { - local_var_req_builder = - local_var_req_builder.query(&[("platform", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_platform { + req_builder = req_builder.query(&[("platform", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = user_id { - local_var_req_builder = - local_var_req_builder.query(&[("userId", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_user_id { + req_builder = req_builder.query(&[("userId", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::FavoritedWorld>`"))), + 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<models::FavoritedWorld>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -522,86 +535,93 @@ pub async fn get_recent_worlds( platform: Option<&str>, user_id: Option<&str>, ) -> Result, Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_featured = featured; + let p_query_sort = sort; + let p_query_n = n; + let p_query_order = order; + let p_query_offset = offset; + let p_query_search = search; + let p_query_tag = tag; + let p_query_notag = notag; + let p_query_release_status = release_status; + let p_query_max_unity_version = max_unity_version; + let p_query_min_unity_version = min_unity_version; + let p_query_platform = platform; + let p_query_user_id = user_id; - let local_var_client = &local_var_configuration.client; + let uri_str = format!("{}/worlds/recent", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_uri_str = format!("{}/worlds/recent", 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_str) = featured { - local_var_req_builder = - local_var_req_builder.query(&[("featured", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_featured { + req_builder = req_builder.query(&[("featured", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = sort { - local_var_req_builder = - local_var_req_builder.query(&[("sort", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_sort { + req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = order { - local_var_req_builder = - local_var_req_builder.query(&[("order", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_order { + req_builder = req_builder.query(&[("order", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = search { - local_var_req_builder = - local_var_req_builder.query(&[("search", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_search { + req_builder = req_builder.query(&[("search", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = tag { - local_var_req_builder = local_var_req_builder.query(&[("tag", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_tag { + req_builder = req_builder.query(&[("tag", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = notag { - local_var_req_builder = - local_var_req_builder.query(&[("notag", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_notag { + req_builder = req_builder.query(&[("notag", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = release_status { - local_var_req_builder = - local_var_req_builder.query(&[("releaseStatus", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_release_status { + req_builder = req_builder.query(&[("releaseStatus", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = max_unity_version { - local_var_req_builder = - local_var_req_builder.query(&[("maxUnityVersion", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_max_unity_version { + req_builder = req_builder.query(&[("maxUnityVersion", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = min_unity_version { - local_var_req_builder = - local_var_req_builder.query(&[("minUnityVersion", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_min_unity_version { + req_builder = req_builder.query(&[("minUnityVersion", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = platform { - local_var_req_builder = - local_var_req_builder.query(&[("platform", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_platform { + req_builder = req_builder.query(&[("platform", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = user_id { - local_var_req_builder = - local_var_req_builder.query(&[("userId", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_user_id { + req_builder = req_builder.query(&[("userId", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::LimitedWorld>`"))), + 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<models::LimitedWorld>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -610,39 +630,46 @@ pub async fn get_world( configuration: &configuration::Configuration, world_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_world_id = world_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/worlds/{worldId}", - local_var_configuration.base_path, - worldId = crate::apis::urlencode(world_id) + configuration.base_path, + worldId = crate::apis::urlencode(p_path_world_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::World`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::World`")))), + } } else { - let local_var_entity: Option = 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -652,83 +679,97 @@ pub async fn get_world_instance( world_id: &str, instance_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_world_id = world_id; + let p_path_instance_id = instance_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/worlds/{worldId}/{instanceId}", - local_var_configuration.base_path, - worldId = crate::apis::urlencode(world_id), - instanceId = crate::apis::urlencode(instance_id) + configuration.base_path, + worldId = crate::apis::urlencode(p_path_world_id), + instanceId = crate::apis::urlencode(p_path_instance_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::Instance`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Instance`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } /// Return a worlds custom metadata. This is currently believed to be unused. Metadata can be set with `updateWorld` and can be any arbitrary object. +#[deprecated] pub async fn get_world_metadata( configuration: &configuration::Configuration, world_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_world_id = world_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/worlds/{worldId}/metadata", - local_var_configuration.base_path, - worldId = crate::apis::urlencode(world_id) + configuration.base_path, + worldId = crate::apis::urlencode(p_path_world_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::WorldMetadata`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::WorldMetadata`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -737,40 +778,46 @@ pub async fn get_world_publish_status( configuration: &configuration::Configuration, world_id: &str, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_world_id = world_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/worlds/{worldId}/publish", - local_var_configuration.base_path, - worldId = crate::apis::urlencode(world_id) + configuration.base_path, + worldId = crate::apis::urlencode(p_path_world_id) ); - 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()); - } - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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()); + } + + 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 `models::WorldPublishStatus`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::WorldPublishStatus`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -779,40 +826,35 @@ pub async fn publish_world( configuration: &configuration::Configuration, world_id: &str, ) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_world_id = world_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/worlds/{worldId}/publish", - local_var_configuration.base_path, - worldId = crate::apis::urlencode(world_id) + configuration.base_path, + worldId = crate::apis::urlencode(p_path_world_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -835,94 +877,101 @@ pub async fn search_worlds( platform: Option<&str>, fuzzy: Option, ) -> Result, Error> { - let local_var_configuration = configuration; + // add a prefix to parameters to efficiently prevent name collisions + let p_query_featured = featured; + let p_query_sort = sort; + let p_query_user = user; + let p_query_user_id = user_id; + let p_query_n = n; + let p_query_order = order; + let p_query_offset = offset; + let p_query_search = search; + let p_query_tag = tag; + let p_query_notag = notag; + let p_query_release_status = release_status; + let p_query_max_unity_version = max_unity_version; + let p_query_min_unity_version = min_unity_version; + let p_query_platform = platform; + let p_query_fuzzy = fuzzy; - let local_var_client = &local_var_configuration.client; + let uri_str = format!("{}/worlds", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_uri_str = format!("{}/worlds", 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_str) = featured { - local_var_req_builder = - local_var_req_builder.query(&[("featured", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_featured { + req_builder = req_builder.query(&[("featured", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = sort { - local_var_req_builder = - local_var_req_builder.query(&[("sort", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_sort { + req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = user { - local_var_req_builder = - local_var_req_builder.query(&[("user", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_user { + req_builder = req_builder.query(&[("user", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = user_id { - local_var_req_builder = - local_var_req_builder.query(&[("userId", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_user_id { + req_builder = req_builder.query(&[("userId", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = n { - local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_n { + req_builder = req_builder.query(&[("n", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = order { - local_var_req_builder = - local_var_req_builder.query(&[("order", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_order { + req_builder = req_builder.query(&[("order", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = offset { - local_var_req_builder = - local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_offset { + req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = search { - local_var_req_builder = - local_var_req_builder.query(&[("search", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_search { + req_builder = req_builder.query(&[("search", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = tag { - local_var_req_builder = local_var_req_builder.query(&[("tag", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_tag { + req_builder = req_builder.query(&[("tag", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = notag { - local_var_req_builder = - local_var_req_builder.query(&[("notag", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_notag { + req_builder = req_builder.query(&[("notag", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = release_status { - local_var_req_builder = - local_var_req_builder.query(&[("releaseStatus", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_release_status { + req_builder = req_builder.query(&[("releaseStatus", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = max_unity_version { - local_var_req_builder = - local_var_req_builder.query(&[("maxUnityVersion", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_max_unity_version { + req_builder = req_builder.query(&[("maxUnityVersion", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = min_unity_version { - local_var_req_builder = - local_var_req_builder.query(&[("minUnityVersion", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_min_unity_version { + req_builder = req_builder.query(&[("minUnityVersion", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = platform { - local_var_req_builder = - local_var_req_builder.query(&[("platform", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_platform { + req_builder = req_builder.query(&[("platform", ¶m_value.to_string())]); } - if let Some(ref local_var_str) = fuzzy { - local_var_req_builder = - local_var_req_builder.query(&[("fuzzy", &local_var_str.to_string())]); + if let Some(ref param_value) = p_query_fuzzy { + req_builder = req_builder.query(&[("fuzzy", ¶m_value.to_string())]); } - 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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().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 !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + 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<models::LimitedWorld>`"))), + 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<models::LimitedWorld>`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -931,40 +980,37 @@ pub async fn unpublish_world( configuration: &configuration::Configuration, world_id: &str, ) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_world_id = world_id; - let local_var_uri_str = format!( + let uri_str = format!( "{}/worlds/{worldId}/publish", - local_var_configuration.base_path, - worldId = crate::apis::urlencode(world_id) + configuration.base_path, + worldId = crate::apis::urlencode(p_path_world_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_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 user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } @@ -974,40 +1020,47 @@ pub async fn update_world( world_id: &str, update_world_request: Option, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; + // add a prefix to parameters to efficiently prevent name collisions + let p_path_world_id = world_id; + let p_body_update_world_request = update_world_request; - let local_var_uri_str = format!( + let uri_str = format!( "{}/worlds/{worldId}", - local_var_configuration.base_path, - worldId = crate::apis::urlencode(world_id) + configuration.base_path, + worldId = crate::apis::urlencode(p_path_world_id) ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, 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(&update_world_request); - - 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() { - serde_json::from_str(&local_var_content).map_err(Error::from) + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(&p_body_update_world_request); + + 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 `models::World`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::World`")))), + } } else { - let local_var_entity: Option = - 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)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } diff --git a/src/lib.rs b/src/lib.rs index d91a0d6..9556a0a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,6 +4,7 @@ extern crate reqwest; extern crate serde; extern crate serde_json; +extern crate serde_repr; extern crate url; pub mod apis; diff --git a/src/models/group_search_sort.rs b/src/models/group_search_sort.rs index fa8687f..b3c4761 100644 --- a/src/models/group_search_sort.rs +++ b/src/models/group_search_sort.rs @@ -12,22 +12,22 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] pub enum GroupSearchSort { #[serde(rename = "joinedAt:asc")] - Asc, + JoinedAtColonAsc, #[serde(rename = "joinedAt:desc")] - Desc, + JoinedAtColonDesc, } impl std::fmt::Display for GroupSearchSort { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { - Self::Asc => write!(f, "joinedAt:asc"), - Self::Desc => write!(f, "joinedAt:desc"), + Self::JoinedAtColonAsc => write!(f, "joinedAt:asc"), + Self::JoinedAtColonDesc => write!(f, "joinedAt:desc"), } } } impl Default for GroupSearchSort { fn default() -> GroupSearchSort { - Self::Asc + Self::JoinedAtColonAsc } } From d433dbcf13593b3455810df81327c78debbd482d Mon Sep 17 00:00:00 2001 From: C0D3 M4513R <28912031+C0D3-M4513R@users.noreply.github.com> Date: Wed, 3 Dec 2025 19:34:16 +0100 Subject: [PATCH 3/6] Remove sccache --- .github/workflows/check_pr.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/check_pr.yaml b/.github/workflows/check_pr.yaml index a04ef3b..56fcfe0 100644 --- a/.github/workflows/check_pr.yaml +++ b/.github/workflows/check_pr.yaml @@ -16,12 +16,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: moonrepo/setup-rust@v1 - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.6 - - name: Configure sccache env var and set build profile to ephemeral build - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV - run: cargo build --all - run: cargo test --all From b047e29a6659849cc7cf49abcecc798a54582495 Mon Sep 17 00:00:00 2001 From: C0D3 M4513R <28912031+C0D3-M4513R@users.noreply.github.com> Date: Wed, 3 Dec 2025 20:16:18 +0100 Subject: [PATCH 4/6] Hide warnings about non-camel-case-types --- generate.sh | 3 +++ src/lib.rs | 1 + 2 files changed, 4 insertions(+) diff --git a/generate.sh b/generate.sh index 8799fca..919e28f 100755 --- a/generate.sh +++ b/generate.sh @@ -45,6 +45,9 @@ find src/ -type f -name "*.rs" -exec sed -i 's/models::models/models/g' {} + find src/ -type f -name "*.rs" -exec sed -i 's/multipart_form\.text("data", p_form_data\.to_string())/multipart_form.text("data", serde_json::to_string_pretty(\&p_form_data)?)/g' {} + +#Hide warnings about unused variables and non-rusty type names +sed -i 's/#!\[allow(unused_imports)\]/#![allow(unused_imports)]\n#![allow(non_camel_case_types)]/' src/lib.rs + cargo fmt cargo build cargo test diff --git a/src/lib.rs b/src/lib.rs index 9556a0a..5dfd2fe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ #![allow(unused_imports)] +#![allow(non_camel_case_types)] #![allow(clippy::too_many_arguments)] extern crate reqwest; From 5febac847c8425e386bbdb9c176ddfa7c71d222c Mon Sep 17 00:00:00 2001 From: C0D3 M4513R <28912031+C0D3-M4513R@users.noreply.github.com> Date: Wed, 3 Dec 2025 20:17:22 +0100 Subject: [PATCH 5/6] Implement Multipart handling for generic parameters --- generate.sh | 5 ++++- src/apis/invite_api.rs | 27 +++++++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/generate.sh b/generate.sh index 919e28f..b7a9d17 100755 --- a/generate.sh +++ b/generate.sh @@ -39,7 +39,10 @@ sed -i 's/Result>/Result>,\n\tfilename: impl Into<::std::borrow::Cow<'\''static, str>>,\n\tmime_type: &str,\2\3let part = reqwest::multipart::Part::bytes(p_form_file).file_name(filename).mime_str(mime_type)?;\n\tmultipart_form = multipart_form.part("file", part);|g' src/apis/files_api.rs +#perl -0pi -e 's|(fn\s+[^(]*\([^)]*)file:\s+:?:?std::path::PathBuf,?([^)]*)((?:(?!\/\/ TODO: support file upload for '\''file'\'' parameter)[\s\S])*)\/\/ TODO: support file upload for '\''file'\'' parameter|\1file: impl Into<::std::borrow::Cow<'\''static, [u8]>>,\n\tfilename: impl Into<::std::borrow::Cow<'\''static, str>>,\n\tmime_type: &str,\2\3let part = reqwest::multipart::Part::bytes(p_form_file).file_name(filename).mime_str(mime_type)?;\n\tmultipart_form = multipart_form.part("file", part);|g' src/apis/files_api.rs +#perl -0pi -e 's|(fn\s+[^(]*\([^)]*)image:\s+:?:?std::path::PathBuf,?([^)]*)((?:(?!\/\/ TODO: support file upload for '\''image'\'' parameter)[\s\S])*)\/\/ TODO: support file upload for '\''image'\'' parameter|\1image: impl Into<::std::borrow::Cow<'\''static, [u8]>>,\n\tfilename: impl Into<::std::borrow::Cow<'\''static, str>>,\n\tmime_type: &str,\2\3let part = reqwest::multipart::Part::bytes(p_form_image).file_name(filename).mime_str(mime_type)?;\n\tmultipart_form = multipart_form.part("image", part);|g' src/apis/invite_api.rs +#This is basically the multipart handling from above, except put in one regex replace +perl -0pi -e 's|(fn\s+[^(]*\([^)]*)([,\s])([\w]+):\s+(?:::)?std::path::PathBuf,?([^)]*)((?:(?!\/\/ TODO: support file upload for '\''\3'\'' parameter)[\s\S])*)\/\/ TODO: support file upload for '\''\3'\'' parameter|\1\2\3: impl Into<::std::borrow::Cow<'\''static, [u8]>>,\n\tfilename: impl Into<::std::borrow::Cow<'\''static, str>>,\n\tmime_type: &str,\4\5let part = reqwest::multipart::Part::bytes(p_form_\3).file_name(filename).mime_str(mime_type)?;\n\tmultipart_form = multipart_form.part("\3", part);|g' src/apis/files_api.rs src/apis/invite_api.rs find src/ -type f -name "*.rs" -exec sed -i 's/models::models/models/g' {} + diff --git a/src/apis/invite_api.rs b/src/apis/invite_api.rs index e58d46e..221332c 100644 --- a/src/apis/invite_api.rs +++ b/src/apis/invite_api.rs @@ -323,7 +323,9 @@ pub async fn invite_user( pub async fn invite_user_with_photo( configuration: &configuration::Configuration, user_id: &str, - image: std::path::PathBuf, + image: impl Into<::std::borrow::Cow<'static, [u8]>>, + filename: impl Into<::std::borrow::Cow<'static, str>>, + mime_type: &str, data: models::InviteRequest, ) -> Result> { // add a prefix to parameters to efficiently prevent name collisions @@ -344,7 +346,10 @@ pub async fn invite_user_with_photo( req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } let mut multipart_form = reqwest::multipart::Form::new(); - // TODO: support file upload for 'image' parameter + let part = reqwest::multipart::Part::bytes(p_form_image) + .file_name(filename) + .mime_str(mime_type)?; + multipart_form = multipart_form.part("image", part); multipart_form = multipart_form.text("data", serde_json::to_string_pretty(&p_form_data)?); req_builder = req_builder.multipart(multipart_form); @@ -434,7 +439,9 @@ pub async fn request_invite( pub async fn request_invite_with_photo( configuration: &configuration::Configuration, user_id: &str, - image: std::path::PathBuf, + image: impl Into<::std::borrow::Cow<'static, [u8]>>, + filename: impl Into<::std::borrow::Cow<'static, str>>, + mime_type: &str, data: models::RequestInviteRequest, ) -> Result> { // add a prefix to parameters to efficiently prevent name collisions @@ -455,7 +462,10 @@ pub async fn request_invite_with_photo( req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } let mut multipart_form = reqwest::multipart::Form::new(); - // TODO: support file upload for 'image' parameter + let part = reqwest::multipart::Part::bytes(p_form_image) + .file_name(filename) + .mime_str(mime_type)?; + multipart_form = multipart_form.part("image", part); multipart_form = multipart_form.text("data", serde_json::to_string_pretty(&p_form_data)?); req_builder = req_builder.multipart(multipart_form); @@ -601,7 +611,9 @@ pub async fn respond_invite( pub async fn respond_invite_with_photo( configuration: &configuration::Configuration, notification_id: &str, - image: std::path::PathBuf, + image: impl Into<::std::borrow::Cow<'static, [u8]>>, + filename: impl Into<::std::borrow::Cow<'static, str>>, + mime_type: &str, data: models::InviteResponse, ) -> Result> { // add a prefix to parameters to efficiently prevent name collisions @@ -622,7 +634,10 @@ pub async fn respond_invite_with_photo( req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } let mut multipart_form = reqwest::multipart::Form::new(); - // TODO: support file upload for 'image' parameter + let part = reqwest::multipart::Part::bytes(p_form_image) + .file_name(filename) + .mime_str(mime_type)?; + multipart_form = multipart_form.part("image", part); multipart_form = multipart_form.text("data", serde_json::to_string_pretty(&p_form_data)?); req_builder = req_builder.multipart(multipart_form); From 8b22e54de0e6f65ef782cc0b710a19ffd070a79b Mon Sep 17 00:00:00 2001 From: C0D3 M4513R <28912031+C0D3-M4513R@users.noreply.github.com> Date: Wed, 3 Dec 2025 20:47:39 +0100 Subject: [PATCH 6/6] Also apply Multipart handling patch onto prints_api.rs --- generate.sh | 2 +- src/apis/prints_api.rs | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/generate.sh b/generate.sh index b7a9d17..247f96a 100755 --- a/generate.sh +++ b/generate.sh @@ -42,7 +42,7 @@ sed -i "s/local_var_req_builder = local_var_req_builder.json(&\(.*\));/if let So #perl -0pi -e 's|(fn\s+[^(]*\([^)]*)file:\s+:?:?std::path::PathBuf,?([^)]*)((?:(?!\/\/ TODO: support file upload for '\''file'\'' parameter)[\s\S])*)\/\/ TODO: support file upload for '\''file'\'' parameter|\1file: impl Into<::std::borrow::Cow<'\''static, [u8]>>,\n\tfilename: impl Into<::std::borrow::Cow<'\''static, str>>,\n\tmime_type: &str,\2\3let part = reqwest::multipart::Part::bytes(p_form_file).file_name(filename).mime_str(mime_type)?;\n\tmultipart_form = multipart_form.part("file", part);|g' src/apis/files_api.rs #perl -0pi -e 's|(fn\s+[^(]*\([^)]*)image:\s+:?:?std::path::PathBuf,?([^)]*)((?:(?!\/\/ TODO: support file upload for '\''image'\'' parameter)[\s\S])*)\/\/ TODO: support file upload for '\''image'\'' parameter|\1image: impl Into<::std::borrow::Cow<'\''static, [u8]>>,\n\tfilename: impl Into<::std::borrow::Cow<'\''static, str>>,\n\tmime_type: &str,\2\3let part = reqwest::multipart::Part::bytes(p_form_image).file_name(filename).mime_str(mime_type)?;\n\tmultipart_form = multipart_form.part("image", part);|g' src/apis/invite_api.rs #This is basically the multipart handling from above, except put in one regex replace -perl -0pi -e 's|(fn\s+[^(]*\([^)]*)([,\s])([\w]+):\s+(?:::)?std::path::PathBuf,?([^)]*)((?:(?!\/\/ TODO: support file upload for '\''\3'\'' parameter)[\s\S])*)\/\/ TODO: support file upload for '\''\3'\'' parameter|\1\2\3: impl Into<::std::borrow::Cow<'\''static, [u8]>>,\n\tfilename: impl Into<::std::borrow::Cow<'\''static, str>>,\n\tmime_type: &str,\4\5let part = reqwest::multipart::Part::bytes(p_form_\3).file_name(filename).mime_str(mime_type)?;\n\tmultipart_form = multipart_form.part("\3", part);|g' src/apis/files_api.rs src/apis/invite_api.rs +perl -0pi -e 's|(fn\s+[^(]*\([^)]*)([,\s])([\w]+):\s+(?:::)?std::path::PathBuf,?([^)]*)((?:(?!\/\/ TODO: support file upload for '\''\3'\'' parameter)[\s\S])*)\/\/ TODO: support file upload for '\''\3'\'' parameter|\1\2\3: impl Into<::std::borrow::Cow<'\''static, [u8]>>,\n\tfilename: impl Into<::std::borrow::Cow<'\''static, str>>,\n\tmime_type: &str,\4\5let part = reqwest::multipart::Part::bytes(p_form_\3).file_name(filename).mime_str(mime_type)?;\n\tmultipart_form = multipart_form.part("\3", part);|g' src/apis/files_api.rs src/apis/invite_api.rs src/apis/prints_api.rs find src/ -type f -name "*.rs" -exec sed -i 's/models::models/models/g' {} + diff --git a/src/apis/prints_api.rs b/src/apis/prints_api.rs index 5af18f7..df16cc5 100644 --- a/src/apis/prints_api.rs +++ b/src/apis/prints_api.rs @@ -95,7 +95,9 @@ pub async fn delete_print( pub async fn edit_print( configuration: &configuration::Configuration, print_id: &str, - image: std::path::PathBuf, + image: impl Into<::std::borrow::Cow<'static, [u8]>>, + filename: impl Into<::std::borrow::Cow<'static, str>>, + mime_type: &str, note: Option<&str>, ) -> Result> { // add a prefix to parameters to efficiently prevent name collisions @@ -116,7 +118,10 @@ pub async fn edit_print( req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } let mut multipart_form = reqwest::multipart::Form::new(); - // TODO: support file upload for 'image' parameter + let part = reqwest::multipart::Part::bytes(p_form_image) + .file_name(filename) + .mime_str(mime_type)?; + multipart_form = multipart_form.part("image", part); if let Some(param_value) = p_form_note { multipart_form = multipart_form.text("note", param_value.to_string()); } @@ -250,7 +255,9 @@ pub async fn get_user_prints( /// Uploads and creates a print. pub async fn upload_print( configuration: &configuration::Configuration, - image: std::path::PathBuf, + image: impl Into<::std::borrow::Cow<'static, [u8]>>, + filename: impl Into<::std::borrow::Cow<'static, str>>, + mime_type: &str, timestamp: String, note: Option<&str>, world_id: Option<&str>, @@ -272,7 +279,10 @@ pub async fn upload_print( req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } let mut multipart_form = reqwest::multipart::Form::new(); - // TODO: support file upload for 'image' parameter + let part = reqwest::multipart::Part::bytes(p_form_image) + .file_name(filename) + .mime_str(mime_type)?; + multipart_form = multipart_form.part("image", part); multipart_form = multipart_form.text("timestamp", p_form_timestamp.to_string()); if let Some(param_value) = p_form_note { multipart_form = multipart_form.text("note", param_value.to_string());