diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-12-09 13:01:20 +0100 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-12-09 13:01:20 +0100 |
| commit | 24a1c946b7017237627d69d293c05237d9b96ca5 (patch) | |
| tree | fc9669287a86df5bc863507743ca9961519bef86 /crates/rocie-client/src/apis | |
| parent | chore(crates/rocie-client): Re-generate (diff) | |
| download | server-24a1c946b7017237627d69d293c05237d9b96ca5.zip | |
chore(rocie-client): Regenerate
This also adds cookie persisting to the default configuration.
Diffstat (limited to 'crates/rocie-client/src/apis')
18 files changed, 1791 insertions, 16 deletions
diff --git a/crates/rocie-client/src/apis/api_get_auth_inventory_api.rs b/crates/rocie-client/src/apis/api_get_auth_inventory_api.rs new file mode 100644 index 0000000..6249b62 --- /dev/null +++ b/crates/rocie-client/src/apis/api_get_auth_inventory_api.rs @@ -0,0 +1,64 @@ +/* + * rocie-server + * + * An enterprise grocery management system - server + * + * The version of the OpenAPI document: 0.1.0 + * Contact: benedikt.peetz@b-peetz.de + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`amount_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AmountByIdError { + Status401(), + Status404(), + Status500(String), + UnknownValue(serde_json::Value), +} + + +pub async fn amount_by_id(configuration: &configuration::Configuration, id: models::ProductId) -> Result<models::ProductAmount, Error<AmountByIdError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + + let uri_str = format!("{}/inventory/{id}", configuration.base_path, id=p_id.to_string()); + 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::ProductAmount`"))), + 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::ProductAmount`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<AmountByIdError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/crates/rocie-client/src/apis/api_get_auth_product_api.rs b/crates/rocie-client/src/apis/api_get_auth_product_api.rs new file mode 100644 index 0000000..dcc35a7 --- /dev/null +++ b/crates/rocie-client/src/apis/api_get_auth_product_api.rs @@ -0,0 +1,335 @@ +/* + * rocie-server + * + * An enterprise grocery management system - server + * + * The version of the OpenAPI document: 0.1.0 + * Contact: benedikt.peetz@b-peetz.de + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`product_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ProductByIdError { + Status401(), + Status404(), + Status500(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`product_by_name`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ProductByNameError { + Status401(), + Status404(), + Status500(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`product_suggestion_by_name`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ProductSuggestionByNameError { + Status401(), + Status500(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`products_by_product_parent_id_direct`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ProductsByProductParentIdDirectError { + Status401(), + Status404(), + Status500(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`products_by_product_parent_id_indirect`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ProductsByProductParentIdIndirectError { + Status401(), + Status404(), + Status500(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`products_in_storage`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ProductsInStorageError { + Status401(), + Status500(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`products_registered`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ProductsRegisteredError { + Status401(), + Status500(String), + UnknownValue(serde_json::Value), +} + + +pub async fn product_by_id(configuration: &configuration::Configuration, id: models::ProductId) -> Result<models::Product, Error<ProductByIdError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + + let uri_str = format!("{}/product/by-id/{id}", configuration.base_path, id=p_id.to_string()); + 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::Product`"))), + 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::Product`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<ProductByIdError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +pub async fn product_by_name(configuration: &configuration::Configuration, name: &str) -> Result<models::Product, Error<ProductByNameError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_name = name; + + let uri_str = format!("{}/product/by-name/{name}", configuration.base_path, name=crate::apis::urlencode(p_name)); + 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::Product`"))), + 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::Product`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<ProductByNameError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +pub async fn product_suggestion_by_name(configuration: &configuration::Configuration, name: &str) -> Result<Vec<models::Product>, Error<ProductSuggestionByNameError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_name = name; + + let uri_str = format!("{}/product/by-part-name/{name}", configuration.base_path, name=crate::apis::urlencode(p_name)); + 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::Product>`"))), + 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::Product>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<ProductSuggestionByNameError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// This will only return products directly associated with this product parent id +pub async fn products_by_product_parent_id_direct(configuration: &configuration::Configuration, id: models::ProductParentId) -> Result<Vec<models::Product>, Error<ProductsByProductParentIdDirectError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + + let uri_str = format!("{}/product/by-product-parent-id-direct/{id}", configuration.base_path, id=p_id.to_string()); + 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::Product>`"))), + 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::Product>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<ProductsByProductParentIdDirectError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// This will also return all products below this product parent id +pub async fn products_by_product_parent_id_indirect(configuration: &configuration::Configuration, id: models::ProductParentId) -> Result<Vec<models::Product>, Error<ProductsByProductParentIdIndirectError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + + let uri_str = format!("{}/product/by-product-parent-id-indirect/{id}", configuration.base_path, id=p_id.to_string()); + 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::Product>`"))), + 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::Product>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<ProductsByProductParentIdIndirectError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +pub async fn products_in_storage(configuration: &configuration::Configuration, ) -> Result<Vec<models::Product>, Error<ProductsInStorageError>> { + + let uri_str = format!("{}/products_in_storage/", 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::Product>`"))), + 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::Product>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<ProductsInStorageError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +pub async fn products_registered(configuration: &configuration::Configuration, ) -> Result<Vec<models::Product>, Error<ProductsRegisteredError>> { + + let uri_str = format!("{}/products_registered/", 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::Product>`"))), + 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::Product>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<ProductsRegisteredError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/crates/rocie-client/src/apis/api_get_auth_product_parent_api.rs b/crates/rocie-client/src/apis/api_get_auth_product_parent_api.rs new file mode 100644 index 0000000..68b17d7 --- /dev/null +++ b/crates/rocie-client/src/apis/api_get_auth_product_parent_api.rs @@ -0,0 +1,149 @@ +/* + * rocie-server + * + * An enterprise grocery management system - server + * + * The version of the OpenAPI document: 0.1.0 + * Contact: benedikt.peetz@b-peetz.de + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`product_parents`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ProductParentsError { + Status401(), + Status500(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`product_parents_toplevel`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ProductParentsToplevelError { + Status401(), + Status500(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`product_parents_under`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ProductParentsUnderError { + Status401(), + Status500(String), + UnknownValue(serde_json::Value), +} + + +pub async fn product_parents(configuration: &configuration::Configuration, ) -> Result<Vec<models::ProductParent>, Error<ProductParentsError>> { + + let uri_str = format!("{}/product_parents/", 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::ProductParent>`"))), + 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::ProductParent>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<ProductParentsError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +pub async fn product_parents_toplevel(configuration: &configuration::Configuration, ) -> Result<Vec<models::ProductParent>, Error<ProductParentsToplevelError>> { + + let uri_str = format!("{}/product_parents_toplevel/", 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::ProductParent>`"))), + 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::ProductParent>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<ProductParentsToplevelError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +pub async fn product_parents_under(configuration: &configuration::Configuration, id: models::ProductParentId) -> Result<Vec<models::ProductParent>, Error<ProductParentsUnderError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + + let uri_str = format!("{}/product_parents_under/{id}", configuration.base_path, id=p_id.to_string()); + 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::ProductParent>`"))), + 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::ProductParent>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<ProductParentsUnderError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/crates/rocie-client/src/apis/api_get_auth_recipe_api.rs b/crates/rocie-client/src/apis/api_get_auth_recipe_api.rs new file mode 100644 index 0000000..4eddb2f --- /dev/null +++ b/crates/rocie-client/src/apis/api_get_auth_recipe_api.rs @@ -0,0 +1,107 @@ +/* + * rocie-server + * + * An enterprise grocery management system - server + * + * The version of the OpenAPI document: 0.1.0 + * Contact: benedikt.peetz@b-peetz.de + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`recipe_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RecipeByIdError { + Status401(), + Status404(), + Status500(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`recipes`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RecipesError { + Status401(), + Status500(String), + UnknownValue(serde_json::Value), +} + + +pub async fn recipe_by_id(configuration: &configuration::Configuration, id: models::RecipeId) -> Result<models::Recipe, Error<RecipeByIdError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + + let uri_str = format!("{}/recipe/by-id/{id}", configuration.base_path, id=p_id.to_string()); + 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::Recipe`"))), + 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::Recipe`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<RecipeByIdError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +pub async fn recipes(configuration: &configuration::Configuration, ) -> Result<models::Recipe, Error<RecipesError>> { + + let uri_str = format!("{}/recipe/all", 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::Recipe`"))), + 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::Recipe`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<RecipesError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/crates/rocie-client/src/apis/api_get_auth_unit_api.rs b/crates/rocie-client/src/apis/api_get_auth_unit_api.rs new file mode 100644 index 0000000..c1f7e97 --- /dev/null +++ b/crates/rocie-client/src/apis/api_get_auth_unit_api.rs @@ -0,0 +1,152 @@ +/* + * rocie-server + * + * An enterprise grocery management system - server + * + * The version of the OpenAPI document: 0.1.0 + * Contact: benedikt.peetz@b-peetz.de + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`unit_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UnitByIdError { + Status401(), + Status404(), + Status500(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`units`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UnitsError { + Status401(), + Status500(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`units_by_property_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UnitsByPropertyIdError { + Status401(), + Status500(String), + UnknownValue(serde_json::Value), +} + + +pub async fn unit_by_id(configuration: &configuration::Configuration, id: models::UnitId) -> Result<models::Unit, Error<UnitByIdError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + + let uri_str = format!("{}/unit/{id}", configuration.base_path, id=p_id.to_string()); + 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::Unit`"))), + 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::Unit`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<UnitByIdError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +pub async fn units(configuration: &configuration::Configuration, ) -> Result<Vec<models::Unit>, Error<UnitsError>> { + + let uri_str = format!("{}/units/", 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::Unit>`"))), + 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::Unit>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<UnitsError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +pub async fn units_by_property_id(configuration: &configuration::Configuration, id: models::UnitPropertyId) -> Result<Vec<models::Unit>, Error<UnitsByPropertyIdError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + + let uri_str = format!("{}/units-by-property/{id}", configuration.base_path, id=p_id.to_string()); + 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::Unit>`"))), + 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::Unit>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<UnitsByPropertyIdError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/crates/rocie-client/src/apis/api_get_auth_unit_property_api.rs b/crates/rocie-client/src/apis/api_get_auth_unit_property_api.rs new file mode 100644 index 0000000..1359f40 --- /dev/null +++ b/crates/rocie-client/src/apis/api_get_auth_unit_property_api.rs @@ -0,0 +1,107 @@ +/* + * rocie-server + * + * An enterprise grocery management system - server + * + * The version of the OpenAPI document: 0.1.0 + * Contact: benedikt.peetz@b-peetz.de + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`unit_properties`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UnitPropertiesError { + Status401(), + Status500(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`unit_property_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UnitPropertyByIdError { + Status401(), + Status404(), + Status500(String), + UnknownValue(serde_json::Value), +} + + +pub async fn unit_properties(configuration: &configuration::Configuration, ) -> Result<Vec<models::UnitProperty>, Error<UnitPropertiesError>> { + + let uri_str = format!("{}/unit-properties/", 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::UnitProperty>`"))), + 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::UnitProperty>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<UnitPropertiesError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +pub async fn unit_property_by_id(configuration: &configuration::Configuration, id: models::UnitPropertyId) -> Result<models::UnitProperty, Error<UnitPropertyByIdError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + + let uri_str = format!("{}/unit-property/{id}", configuration.base_path, id=p_id.to_string()); + 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::UnitProperty`"))), + 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::UnitProperty`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<UnitPropertyByIdError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/crates/rocie-client/src/apis/api_get_auth_user_api.rs b/crates/rocie-client/src/apis/api_get_auth_user_api.rs new file mode 100644 index 0000000..61e3935 --- /dev/null +++ b/crates/rocie-client/src/apis/api_get_auth_user_api.rs @@ -0,0 +1,108 @@ +/* + * rocie-server + * + * An enterprise grocery management system - server + * + * The version of the OpenAPI document: 0.1.0 + * Contact: benedikt.peetz@b-peetz.de + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`user_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UserByIdError { + Status401(), + Status403(), + Status404(), + Status500(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`users`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UsersError { + Status401(), + Status500(String), + UnknownValue(serde_json::Value), +} + + +pub async fn user_by_id(configuration: &configuration::Configuration, id: models::UserId) -> Result<models::User, Error<UserByIdError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + + let uri_str = format!("{}/user/{id}", configuration.base_path, id=p_id.to_string()); + 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 content = resp.text().await?; + let entity: Option<UserByIdError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +pub async fn users(configuration: &configuration::Configuration, ) -> Result<Vec<models::User>, Error<UsersError>> { + + let uri_str = format!("{}/users", 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::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 `Vec<models::User>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<UsersError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/crates/rocie-client/src/apis/api_get_no_auth_user_api.rs b/crates/rocie-client/src/apis/api_get_no_auth_user_api.rs new file mode 100644 index 0000000..1a5e91d --- /dev/null +++ b/crates/rocie-client/src/apis/api_get_no_auth_user_api.rs @@ -0,0 +1,106 @@ +/* + * rocie-server + * + * An enterprise grocery management system - server + * + * The version of the OpenAPI document: 0.1.0 + * Contact: benedikt.peetz@b-peetz.de + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`user_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UserByIdError { + Status403(), + Status404(), + Status500(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`users`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UsersError { + Status500(String), + UnknownValue(serde_json::Value), +} + + +pub async fn user_by_id(configuration: &configuration::Configuration, id: models::UserId) -> Result<models::User, Error<UserByIdError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + + let uri_str = format!("{}/user/{id}", configuration.base_path, id=p_id.to_string()); + 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 content = resp.text().await?; + let entity: Option<UserByIdError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +pub async fn users(configuration: &configuration::Configuration, ) -> Result<Vec<models::User>, Error<UsersError>> { + + let uri_str = format!("{}/users", 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::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 `Vec<models::User>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<UsersError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/crates/rocie-client/src/apis/api_set_auth_barcode_api.rs b/crates/rocie-client/src/apis/api_set_auth_barcode_api.rs new file mode 100644 index 0000000..494694d --- /dev/null +++ b/crates/rocie-client/src/apis/api_set_auth_barcode_api.rs @@ -0,0 +1,91 @@ +/* + * rocie-server + * + * An enterprise grocery management system - server + * + * The version of the OpenAPI document: 0.1.0 + * Contact: benedikt.peetz@b-peetz.de + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`buy_barcode`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum BuyBarcodeError { + Status401(), + Status404(), + Status500(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`consume_barcode`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ConsumeBarcodeError { + Status401(), + Status404(), + Status500(String), + UnknownValue(serde_json::Value), +} + + +pub async fn buy_barcode(configuration: &configuration::Configuration, barcode_id: models::BarcodeId, times: u32) -> Result<(), Error<BuyBarcodeError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_barcode_id = barcode_id; + let p_times = times; + + let uri_str = format!("{}/barcode/{barcode_id}/buy/{times}", configuration.base_path, barcode_id=p_barcode_id.to_string(), times=p_times); + 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(); + + if !status.is_client_error() && !status.is_server_error() { + Ok(()) + } else { + let content = resp.text().await?; + let entity: Option<BuyBarcodeError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +pub async fn consume_barcode(configuration: &configuration::Configuration, id: models::BarcodeId, unit_amount: models::UnitAmount) -> Result<(), Error<ConsumeBarcodeError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + let p_unit_amount = unit_amount; + + let uri_str = format!("{}/barcode/{id}/consume", configuration.base_path, id=p_id.to_string()); + 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_unit_amount); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + Ok(()) + } else { + let content = resp.text().await?; + let entity: Option<ConsumeBarcodeError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/crates/rocie-client/src/apis/api_set_auth_product_api.rs b/crates/rocie-client/src/apis/api_set_auth_product_api.rs new file mode 100644 index 0000000..fd1cd23 --- /dev/null +++ b/crates/rocie-client/src/apis/api_set_auth_product_api.rs @@ -0,0 +1,102 @@ +/* + * rocie-server + * + * An enterprise grocery management system - server + * + * The version of the OpenAPI document: 0.1.0 + * Contact: benedikt.peetz@b-peetz.de + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`associate_barcode`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AssociateBarcodeError { + Status400(String), + Status401(), + Status404(), + Status500(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`register_product`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RegisterProductError { + Status401(), + Status500(String), + UnknownValue(serde_json::Value), +} + + +pub async fn associate_barcode(configuration: &configuration::Configuration, id: models::ProductId, barcode: models::Barcode) -> Result<(), Error<AssociateBarcodeError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + let p_barcode = barcode; + + let uri_str = format!("{}/product/{id}/associate", configuration.base_path, id=p_id.to_string()); + 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_barcode); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + Ok(()) + } else { + let content = resp.text().await?; + let entity: Option<AssociateBarcodeError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +pub async fn register_product(configuration: &configuration::Configuration, product_stub: models::ProductStub) -> Result<models::ProductId, Error<RegisterProductError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_product_stub = product_stub; + + let uri_str = format!("{}/product/new", 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_product_stub); + + 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::ProductId`"))), + 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::ProductId`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<RegisterProductError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/crates/rocie-client/src/apis/api_set_auth_product_parent_api.rs b/crates/rocie-client/src/apis/api_set_auth_product_parent_api.rs new file mode 100644 index 0000000..6ec3a17 --- /dev/null +++ b/crates/rocie-client/src/apis/api_set_auth_product_parent_api.rs @@ -0,0 +1,64 @@ +/* + * rocie-server + * + * An enterprise grocery management system - server + * + * The version of the OpenAPI document: 0.1.0 + * Contact: benedikt.peetz@b-peetz.de + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`register_product_parent`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RegisterProductParentError { + Status401(), + Status500(String), + UnknownValue(serde_json::Value), +} + + +pub async fn register_product_parent(configuration: &configuration::Configuration, product_parent_stub: models::ProductParentStub) -> Result<models::ProductParentId, Error<RegisterProductParentError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_product_parent_stub = product_parent_stub; + + let uri_str = format!("{}/product_parent/new", 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_product_parent_stub); + + 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::ProductParentId`"))), + 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::ProductParentId`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<RegisterProductParentError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/crates/rocie-client/src/apis/api_set_auth_recipe_api.rs b/crates/rocie-client/src/apis/api_set_auth_recipe_api.rs new file mode 100644 index 0000000..52eb874 --- /dev/null +++ b/crates/rocie-client/src/apis/api_set_auth_recipe_api.rs @@ -0,0 +1,64 @@ +/* + * rocie-server + * + * An enterprise grocery management system - server + * + * The version of the OpenAPI document: 0.1.0 + * Contact: benedikt.peetz@b-peetz.de + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`add_recipe`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AddRecipeError { + Status401(), + Status500(String), + UnknownValue(serde_json::Value), +} + + +pub async fn add_recipe(configuration: &configuration::Configuration, recipe_stub: models::RecipeStub) -> Result<models::RecipeId, Error<AddRecipeError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_recipe_stub = recipe_stub; + + let uri_str = format!("{}/recipe/new", 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_recipe_stub); + + 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::RecipeId`"))), + 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::RecipeId`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<AddRecipeError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/crates/rocie-client/src/apis/api_set_auth_unit_api.rs b/crates/rocie-client/src/apis/api_set_auth_unit_api.rs new file mode 100644 index 0000000..0f96f98 --- /dev/null +++ b/crates/rocie-client/src/apis/api_set_auth_unit_api.rs @@ -0,0 +1,64 @@ +/* + * rocie-server + * + * An enterprise grocery management system - server + * + * The version of the OpenAPI document: 0.1.0 + * Contact: benedikt.peetz@b-peetz.de + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`register_unit`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RegisterUnitError { + Status401(), + Status500(String), + UnknownValue(serde_json::Value), +} + + +pub async fn register_unit(configuration: &configuration::Configuration, unit_stub: models::UnitStub) -> Result<models::UnitId, Error<RegisterUnitError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_unit_stub = unit_stub; + + let uri_str = format!("{}/unit/new", 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_unit_stub); + + 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::UnitId`"))), + 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::UnitId`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<RegisterUnitError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/crates/rocie-client/src/apis/api_set_auth_unit_property_api.rs b/crates/rocie-client/src/apis/api_set_auth_unit_property_api.rs new file mode 100644 index 0000000..bfb8a4d --- /dev/null +++ b/crates/rocie-client/src/apis/api_set_auth_unit_property_api.rs @@ -0,0 +1,64 @@ +/* + * rocie-server + * + * An enterprise grocery management system - server + * + * The version of the OpenAPI document: 0.1.0 + * Contact: benedikt.peetz@b-peetz.de + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`register_unit_property`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RegisterUnitPropertyError { + Status401(), + Status500(String), + UnknownValue(serde_json::Value), +} + + +pub async fn register_unit_property(configuration: &configuration::Configuration, unit_property_stub: models::UnitPropertyStub) -> Result<models::UnitPropertyId, Error<RegisterUnitPropertyError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_unit_property_stub = unit_property_stub; + + let uri_str = format!("{}/unit-property/new", 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_unit_property_stub); + + 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::UnitPropertyId`"))), + 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::UnitPropertyId`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<RegisterUnitPropertyError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/crates/rocie-client/src/apis/api_set_auth_user_api.rs b/crates/rocie-client/src/apis/api_set_auth_user_api.rs new file mode 100644 index 0000000..4f43bbe --- /dev/null +++ b/crates/rocie-client/src/apis/api_set_auth_user_api.rs @@ -0,0 +1,64 @@ +/* + * rocie-server + * + * An enterprise grocery management system - server + * + * The version of the OpenAPI document: 0.1.0 + * Contact: benedikt.peetz@b-peetz.de + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`register_user`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RegisterUserError { + Status401(), + Status500(String), + UnknownValue(serde_json::Value), +} + + +pub async fn register_user(configuration: &configuration::Configuration, user_stub: models::UserStub) -> Result<models::UserId, Error<RegisterUserError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_user_stub = user_stub; + + let uri_str = format!("{}/user/new", 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_user_stub); + + 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::UserId`"))), + 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::UserId`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<RegisterUserError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/crates/rocie-client/src/apis/api_set_no_auth_user_api.rs b/crates/rocie-client/src/apis/api_set_no_auth_user_api.rs new file mode 100644 index 0000000..6a59d1f --- /dev/null +++ b/crates/rocie-client/src/apis/api_set_no_auth_user_api.rs @@ -0,0 +1,132 @@ +/* + * rocie-server + * + * An enterprise grocery management system - server + * + * The version of the OpenAPI document: 0.1.0 + * Contact: benedikt.peetz@b-peetz.de + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`login`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum LoginError { + Status403(), + Status404(), + Status500(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`logout`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum LogoutError { + Status500(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`provision`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ProvisionError { + Status403(), + Status500(String), + UnknownValue(serde_json::Value), +} + + +pub async fn login(configuration: &configuration::Configuration, login_info: models::LoginInfo) -> Result<(), Error<LoginError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_login_info = login_info; + + let uri_str = format!("{}/login", 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_login_info); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + Ok(()) + } else { + let content = resp.text().await?; + let entity: Option<LoginError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +pub async fn logout(configuration: &configuration::Configuration, ) -> Result<(), Error<LogoutError>> { + + let uri_str = format!("{}/logout", 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(); + + if !status.is_client_error() && !status.is_server_error() { + Ok(()) + } else { + let content = resp.text().await?; + let entity: Option<LogoutError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// This only works, if no users exist yet. +pub async fn provision(configuration: &configuration::Configuration, user_stub: models::UserStub) -> Result<models::UserId, Error<ProvisionError>> { + // add a prefix to parameters to efficiently prevent name collisions + let p_user_stub = user_stub; + + let uri_str = format!("{}/provision", 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_user_stub); + + 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::UserId`"))), + 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::UserId`")))), + } + } else { + let content = resp.text().await?; + let entity: Option<ProvisionError> = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/crates/rocie-client/src/apis/configuration.rs b/crates/rocie-client/src/apis/configuration.rs index 590f233..c143926 100644 --- a/crates/rocie-client/src/apis/configuration.rs +++ b/crates/rocie-client/src/apis/configuration.rs @@ -8,8 +8,6 @@ * Generated by: https://openapi-generator.tech */ - - #[derive(Debug, Clone)] pub struct Configuration { pub base_path: String, @@ -29,7 +27,6 @@ pub struct ApiKey { pub key: String, } - impl Configuration { pub fn new() -> Configuration { Configuration::default() @@ -38,10 +35,12 @@ impl Configuration { impl Default for Configuration { fn default() -> Self { + let client = reqwest::Client::builder().cookie_store(true).build().expect("to be not missconfigured"); + Configuration { base_path: "http://localhost".to_owned(), user_agent: Some("OpenAPI-Generator/0.1.0/rust".to_owned()), - client: reqwest::Client::new(), + client, basic_auth: None, oauth_access_token: None, bearer_access_token: None, diff --git a/crates/rocie-client/src/apis/mod.rs b/crates/rocie-client/src/apis/mod.rs index 13e70ba..e1b12e3 100644 --- a/crates/rocie-client/src/apis/mod.rs +++ b/crates/rocie-client/src/apis/mod.rs @@ -111,17 +111,20 @@ impl From<&str> for ContentType { } } -pub mod api_get_inventory_api; -pub mod api_get_product_api; -pub mod api_get_product_parent_api; -pub mod api_get_recipe_api; -pub mod api_get_unit_api; -pub mod api_get_unit_property_api; -pub mod api_set_barcode_api; -pub mod api_set_product_api; -pub mod api_set_product_parent_api; -pub mod api_set_recipe_api; -pub mod api_set_unit_api; -pub mod api_set_unit_property_api; +pub mod api_get_auth_inventory_api; +pub mod api_get_auth_product_api; +pub mod api_get_auth_product_parent_api; +pub mod api_get_auth_recipe_api; +pub mod api_get_auth_unit_api; +pub mod api_get_auth_unit_property_api; +pub mod api_get_auth_user_api; +pub mod api_set_auth_barcode_api; +pub mod api_set_auth_product_api; +pub mod api_set_auth_product_parent_api; +pub mod api_set_auth_recipe_api; +pub mod api_set_auth_unit_api; +pub mod api_set_auth_unit_property_api; +pub mod api_set_auth_user_api; +pub mod api_set_no_auth_user_api; pub mod configuration; |
