diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-11-28 16:35:35 +0100 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-11-28 16:35:35 +0100 |
| commit | a479685602347b473d74f99f492e5e85d7afde94 (patch) | |
| tree | ed7eea0fbab0a9f33d959345719d638271539da0 /crates/rocie-client/src | |
| parent | feat(crates/rocie-cli): Add support for product parents (diff) | |
| download | server-a479685602347b473d74f99f492e5e85d7afde94.zip | |
chore(crates/rocie-client): Re-generate
Diffstat (limited to 'crates/rocie-client/src')
21 files changed, 808 insertions, 20 deletions
diff --git a/crates/rocie-client/src/apis/api_get_product_api.rs b/crates/rocie-client/src/apis/api_get_product_api.rs index 2e18d8a..a4bf9b8 100644 --- a/crates/rocie-client/src/apis/api_get_product_api.rs +++ b/crates/rocie-client/src/apis/api_get_product_api.rs @@ -41,10 +41,36 @@ pub enum ProductSuggestionByNameError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`products`] +/// struct for typed errors of method [`products_by_product_parent_id_direct`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum ProductsError { +pub enum ProductsByProductParentIdDirectError { + 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 { + 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 { + Status500(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`products_registered`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ProductsRegisteredError { Status500(String), UnknownValue(serde_json::Value), } @@ -158,9 +184,117 @@ pub async fn product_suggestion_by_name(configuration: &configuration::Configura } } -pub async fn products(configuration: &configuration::Configuration, ) -> Result<Vec<models::Product>, Error<ProductsError>> { +/// 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/", configuration.base_path); + 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 { @@ -187,7 +321,7 @@ pub async fn products(configuration: &configuration::Configuration, ) -> Result< } } else { let content = resp.text().await?; - let entity: Option<ProductsError> = serde_json::from_str(&content).ok(); + 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_product_parent_api.rs b/crates/rocie-client/src/apis/api_get_product_parent_api.rs new file mode 100644 index 0000000..6adc6e1 --- /dev/null +++ b/crates/rocie-client/src/apis/api_get_product_parent_api.rs @@ -0,0 +1,146 @@ +/* + * 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 { + 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 { + 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 { + 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_recipe_api.rs b/crates/rocie-client/src/apis/api_get_recipe_api.rs new file mode 100644 index 0000000..f29a2ce --- /dev/null +++ b/crates/rocie-client/src/apis/api_get_recipe_api.rs @@ -0,0 +1,105 @@ +/* + * 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 { + Status404(), + Status500(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`recipes`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RecipesError { + 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_unit_api.rs b/crates/rocie-client/src/apis/api_get_unit_api.rs index 927b883..df25b47 100644 --- a/crates/rocie-client/src/apis/api_get_unit_api.rs +++ b/crates/rocie-client/src/apis/api_get_unit_api.rs @@ -32,6 +32,14 @@ pub enum UnitsError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`units_by_property_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UnitsByPropertyIdError { + 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 @@ -103,3 +111,39 @@ pub async fn units(configuration: &configuration::Configuration, ) -> Result<Vec } } +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_set_product_parent_api.rs b/crates/rocie-client/src/apis/api_set_product_parent_api.rs new file mode 100644 index 0000000..a537941 --- /dev/null +++ b/crates/rocie-client/src/apis/api_set_product_parent_api.rs @@ -0,0 +1,63 @@ +/* + * 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 { + 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_recipe_api.rs b/crates/rocie-client/src/apis/api_set_recipe_api.rs new file mode 100644 index 0000000..519f90e --- /dev/null +++ b/crates/rocie-client/src/apis/api_set_recipe_api.rs @@ -0,0 +1,63 @@ +/* + * 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 { + 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/mod.rs b/crates/rocie-client/src/apis/mod.rs index 0853432..13e70ba 100644 --- a/crates/rocie-client/src/apis/mod.rs +++ b/crates/rocie-client/src/apis/mod.rs @@ -113,10 +113,14 @@ 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; diff --git a/crates/rocie-client/src/implies.rs b/crates/rocie-client/src/implies.rs index 382b8ca..e9de0ea 100644 --- a/crates/rocie-client/src/implies.rs +++ b/crates/rocie-client/src/implies.rs @@ -1,6 +1,6 @@ use std::fmt::Display; -use crate::models::{BarcodeId, ProductId, UnitId, UnitPropertyId}; +use crate::models::{BarcodeId, ProductId, ProductParentId, RecipeId, UnitId, UnitPropertyId}; // TODO(@bpeetz): The client generator should just do this. <2025-09-23> @@ -31,3 +31,17 @@ impl Display for UnitPropertyId { } } impl Copy for UnitPropertyId {} + +impl Display for ProductParentId { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.value.fmt(f) + } +} +impl Copy for ProductParentId {} + +impl Display for RecipeId { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.value.fmt(f) + } +} +impl Copy for RecipeId {} diff --git a/crates/rocie-client/src/models/mod.rs b/crates/rocie-client/src/models/mod.rs index 4eabdfc..e053411 100644 --- a/crates/rocie-client/src/models/mod.rs +++ b/crates/rocie-client/src/models/mod.rs @@ -8,8 +8,20 @@ pub mod product_amount; pub use self::product_amount::ProductAmount; pub mod product_id; pub use self::product_id::ProductId; +pub mod product_parent; +pub use self::product_parent::ProductParent; +pub mod product_parent_id; +pub use self::product_parent_id::ProductParentId; +pub mod product_parent_stub; +pub use self::product_parent_stub::ProductParentStub; pub mod product_stub; pub use self::product_stub::ProductStub; +pub mod recipe; +pub use self::recipe::Recipe; +pub mod recipe_id; +pub use self::recipe_id::RecipeId; +pub mod recipe_stub; +pub use self::recipe_stub::RecipeStub; pub mod unit; pub use self::unit::Unit; pub mod unit_amount; diff --git a/crates/rocie-client/src/models/product.rs b/crates/rocie-client/src/models/product.rs index 251046c..2ab9445 100644 --- a/crates/rocie-client/src/models/product.rs +++ b/crates/rocie-client/src/models/product.rs @@ -18,14 +18,17 @@ pub struct Product { #[serde(rename = "associated_bar_codes")] pub associated_bar_codes: Vec<models::Barcode>, /// An optional description of this product. - #[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] - pub description: Option<Option<String>>, + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option<String>, /// The id of the product. #[serde(rename = "id")] pub id: models::ProductId, /// The name of the product. This should be globally unique, to make searching easier for the user. #[serde(rename = "name")] pub name: String, + /// The parent this product has. This is effectively it's anchor in the product DAG. + #[serde(rename = "parent", skip_serializing_if = "Option::is_none")] + pub parent: Option<models::ProductParentId>, /// The property this product is measured in. (This is probably always either Mass, Volume or Quantity). #[serde(rename = "unit_property")] pub unit_property: models::UnitPropertyId, @@ -39,6 +42,7 @@ impl Product { description: None, id, name, + parent: None, unit_property, } } diff --git a/crates/rocie-client/src/models/product_parent.rs b/crates/rocie-client/src/models/product_parent.rs new file mode 100644 index 0000000..7ce26c9 --- /dev/null +++ b/crates/rocie-client/src/models/product_parent.rs @@ -0,0 +1,42 @@ +/* + * 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 crate::models; +use serde::{Deserialize, Serialize}; + +/// ProductParent : The grouping system for products. Every Product can have a related parent, and every parent can have a parent themselves. As such, the products list constructs a DAG. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ProductParent { + /// An optional description of this product parent. + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option<String>, + /// The id of the product parent. + #[serde(rename = "id")] + pub id: models::ProductParentId, + /// The name of the product parent. This should be globally unique, to make searching easier for the user. + #[serde(rename = "name")] + pub name: String, + /// The optional id of the parent of this product parent. This must not form a cycle. + #[serde(rename = "parent", skip_serializing_if = "Option::is_none")] + pub parent: Option<models::ProductParentId>, +} + +impl ProductParent { + /// The grouping system for products. Every Product can have a related parent, and every parent can have a parent themselves. As such, the products list constructs a DAG. + pub fn new(id: models::ProductParentId, name: String) -> ProductParent { + ProductParent { + description: None, + id, + name, + parent: None, + } + } +} + diff --git a/crates/rocie-client/src/models/product_parent_id.rs b/crates/rocie-client/src/models/product_parent_id.rs new file mode 100644 index 0000000..1305117 --- /dev/null +++ b/crates/rocie-client/src/models/product_parent_id.rs @@ -0,0 +1,27 @@ +/* + * 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 crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ProductParentId { + #[serde(rename = "value")] + pub value: uuid::Uuid, +} + +impl ProductParentId { + pub fn new(value: uuid::Uuid) -> ProductParentId { + ProductParentId { + value, + } + } +} + diff --git a/crates/rocie-client/src/models/product_parent_stub.rs b/crates/rocie-client/src/models/product_parent_stub.rs new file mode 100644 index 0000000..a874502 --- /dev/null +++ b/crates/rocie-client/src/models/product_parent_stub.rs @@ -0,0 +1,36 @@ +/* + * 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 crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ProductParentStub { + /// A description. + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option<String>, + /// The name of the product parent + #[serde(rename = "name")] + pub name: String, + /// A parent of this product parent, otherwise the parent will be the root of the parent tree. + #[serde(rename = "parent", skip_serializing_if = "Option::is_none")] + pub parent: Option<models::ProductParentId>, +} + +impl ProductParentStub { + pub fn new(name: String) -> ProductParentStub { + ProductParentStub { + description: None, + name, + parent: None, + } + } +} + diff --git a/crates/rocie-client/src/models/product_stub.rs b/crates/rocie-client/src/models/product_stub.rs index 0328076..76bc086 100644 --- a/crates/rocie-client/src/models/product_stub.rs +++ b/crates/rocie-client/src/models/product_stub.rs @@ -14,14 +14,14 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ProductStub { /// A description. - #[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] - pub description: Option<Option<String>>, + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option<String>, /// The name of the product #[serde(rename = "name")] pub name: String, /// A parent of this product, otherwise the parent will be the root of the parent tree. - #[serde(rename = "parent", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] - pub parent: Option<Option<models::ProductId>>, + #[serde(rename = "parent", skip_serializing_if = "Option::is_none")] + pub parent: Option<models::ProductParentId>, /// The Unit Property to use for this product. #[serde(rename = "unit_property")] pub unit_property: models::UnitPropertyId, diff --git a/crates/rocie-client/src/models/recipe.rs b/crates/rocie-client/src/models/recipe.rs new file mode 100644 index 0000000..81cb6bd --- /dev/null +++ b/crates/rocie-client/src/models/recipe.rs @@ -0,0 +1,33 @@ +/* + * 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 crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Recipe { + #[serde(rename = "content")] + pub content: String, + #[serde(rename = "id")] + pub id: models::RecipeId, + #[serde(rename = "path")] + pub path: String, +} + +impl Recipe { + pub fn new(content: String, id: models::RecipeId, path: String) -> Recipe { + Recipe { + content, + id, + path, + } + } +} + diff --git a/crates/rocie-client/src/models/recipe_id.rs b/crates/rocie-client/src/models/recipe_id.rs new file mode 100644 index 0000000..7d13aed --- /dev/null +++ b/crates/rocie-client/src/models/recipe_id.rs @@ -0,0 +1,27 @@ +/* + * 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 crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct RecipeId { + #[serde(rename = "value")] + pub value: uuid::Uuid, +} + +impl RecipeId { + pub fn new(value: uuid::Uuid) -> RecipeId { + RecipeId { + value, + } + } +} + diff --git a/crates/rocie-client/src/models/recipe_stub.rs b/crates/rocie-client/src/models/recipe_stub.rs new file mode 100644 index 0000000..e8e9c63 --- /dev/null +++ b/crates/rocie-client/src/models/recipe_stub.rs @@ -0,0 +1,32 @@ +/* + * 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 crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct RecipeStub { + /// The content of this recipe, in cooklang format + #[serde(rename = "content")] + pub content: String, + /// The path the recipe should have + #[serde(rename = "path")] + pub path: String, +} + +impl RecipeStub { + pub fn new(content: String, path: String) -> RecipeStub { + RecipeStub { + content, + path, + } + } +} + diff --git a/crates/rocie-client/src/models/unit.rs b/crates/rocie-client/src/models/unit.rs index 6361a1c..873cb33 100644 --- a/crates/rocie-client/src/models/unit.rs +++ b/crates/rocie-client/src/models/unit.rs @@ -14,8 +14,8 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Unit { /// Description of this unit. - #[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] - pub description: Option<Option<String>>, + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option<String>, /// The plural version of this unit's name. Is used by a value of two and more. (We do not support Slovenian dual numerus versions) E.g.: Kilogram -> Kilograms gram -> meters #[serde(rename = "full_name_plural")] pub full_name_plural: String, diff --git a/crates/rocie-client/src/models/unit_property.rs b/crates/rocie-client/src/models/unit_property.rs index f62012b..b4dfbe1 100644 --- a/crates/rocie-client/src/models/unit_property.rs +++ b/crates/rocie-client/src/models/unit_property.rs @@ -15,8 +15,8 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UnitProperty { /// An description of this property. - #[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] - pub description: Option<Option<String>>, + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option<String>, /// The unique ID for this unit property. #[serde(rename = "id")] pub id: models::UnitPropertyId, diff --git a/crates/rocie-client/src/models/unit_property_stub.rs b/crates/rocie-client/src/models/unit_property_stub.rs index be2d31e..c43d91e 100644 --- a/crates/rocie-client/src/models/unit_property_stub.rs +++ b/crates/rocie-client/src/models/unit_property_stub.rs @@ -13,8 +13,10 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UnitPropertyStub { - #[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] - pub description: Option<Option<String>>, + /// An optional description of the unit property. + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option<String>, + /// The name of the unit property. #[serde(rename = "name")] pub name: String, } diff --git a/crates/rocie-client/src/models/unit_stub.rs b/crates/rocie-client/src/models/unit_stub.rs index aafad6c..162674f 100644 --- a/crates/rocie-client/src/models/unit_stub.rs +++ b/crates/rocie-client/src/models/unit_stub.rs @@ -13,8 +13,8 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UnitStub { - #[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] - pub description: Option<Option<String>>, + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option<String>, #[serde(rename = "full_name_plural")] pub full_name_plural: String, #[serde(rename = "full_name_singular")] |
