diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-10-08 12:05:36 +0200 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-10-08 12:05:36 +0200 |
| commit | 56f72f4d4c39588fe50414a4db1e8e345047c5d2 (patch) | |
| tree | a542157074c81a724eee6b30a6c26c1f5b3493de /crates/rocie-client | |
| parent | feat(crates/rocie-cli): Add support for unit-properties (diff) | |
| download | server-56f72f4d4c39588fe50414a4db1e8e345047c5d2.zip | |
chore(crates/rocie-client): Re-generate
Diffstat (limited to 'crates/rocie-client')
36 files changed, 503 insertions, 35 deletions
diff --git a/crates/rocie-client/.openapi-generator/FILES b/crates/rocie-client/.openapi-generator/FILES index 8306709..053b1f2 100644 --- a/crates/rocie-client/.openapi-generator/FILES +++ b/crates/rocie-client/.openapi-generator/FILES @@ -4,9 +4,11 @@ README.md docs/ApiGetInventoryApi.md docs/ApiGetProductApi.md docs/ApiGetUnitApi.md +docs/ApiGetUnitPropertyApi.md docs/ApiSetBarcodeApi.md docs/ApiSetProductApi.md docs/ApiSetUnitApi.md +docs/ApiSetUnitPropertyApi.md docs/Barcode.md docs/BarcodeId.md docs/Product.md @@ -16,14 +18,19 @@ docs/ProductStub.md docs/Unit.md docs/UnitAmount.md docs/UnitId.md +docs/UnitProperty.md +docs/UnitPropertyId.md +docs/UnitPropertyStub.md docs/UnitStub.md git_push.sh src/apis/api_get_inventory_api.rs src/apis/api_get_product_api.rs src/apis/api_get_unit_api.rs +src/apis/api_get_unit_property_api.rs src/apis/api_set_barcode_api.rs src/apis/api_set_product_api.rs src/apis/api_set_unit_api.rs +src/apis/api_set_unit_property_api.rs src/apis/configuration.rs src/apis/mod.rs src/models/barcode.rs @@ -36,4 +43,7 @@ src/models/product_stub.rs src/models/unit.rs src/models/unit_amount.rs src/models/unit_id.rs +src/models/unit_property.rs +src/models/unit_property_id.rs +src/models/unit_property_stub.rs src/models/unit_stub.rs diff --git a/crates/rocie-client/README.md b/crates/rocie-client/README.md index 38c4f5e..c01f023 100644 --- a/crates/rocie-client/README.md +++ b/crates/rocie-client/README.md @@ -1,6 +1,6 @@ # Rust API client for rocie-client -An enterprise grocery management system +An enterprise grocery management system - server ## Overview @@ -31,11 +31,14 @@ Class | Method | HTTP request | Description *ApiGetProductApi* | [**products**](docs/ApiGetProductApi.md#products) | **GET** /products/ | Return all registered products *ApiGetUnitApi* | [**unit_by_id**](docs/ApiGetUnitApi.md#unit_by_id) | **GET** /unit/{id} | Get Unit by id *ApiGetUnitApi* | [**units**](docs/ApiGetUnitApi.md#units) | **GET** /units/ | Return all registered units +*ApiGetUnitPropertyApi* | [**unit_properties**](docs/ApiGetUnitPropertyApi.md#unit_properties) | **GET** /unit-properties/ | Return all registered unit properties +*ApiGetUnitPropertyApi* | [**unit_property_by_id**](docs/ApiGetUnitPropertyApi.md#unit_property_by_id) | **GET** /unit-property/{id} | Get Unit property by id *ApiSetBarcodeApi* | [**buy_barcode**](docs/ApiSetBarcodeApi.md#buy_barcode) | **POST** /barcode/{id}/buy | Buy an barcode *ApiSetBarcodeApi* | [**consume_barcode**](docs/ApiSetBarcodeApi.md#consume_barcode) | **POST** /barcode/{id}/consume | Consume an barcode *ApiSetProductApi* | [**associate_barcode**](docs/ApiSetProductApi.md#associate_barcode) | **POST** /product/{id}/associate | Associate a barcode with a product *ApiSetProductApi* | [**register_product**](docs/ApiSetProductApi.md#register_product) | **POST** /product/new | Register a product *ApiSetUnitApi* | [**register_unit**](docs/ApiSetUnitApi.md#register_unit) | **POST** /unit/new | Register an Unit +*ApiSetUnitPropertyApi* | [**register_unit_property**](docs/ApiSetUnitPropertyApi.md#register_unit_property) | **POST** /unit-property/new | Register an Unit Property ## Documentation For Models @@ -49,6 +52,9 @@ Class | Method | HTTP request | Description - [Unit](docs/Unit.md) - [UnitAmount](docs/UnitAmount.md) - [UnitId](docs/UnitId.md) + - [UnitProperty](docs/UnitProperty.md) + - [UnitPropertyId](docs/UnitPropertyId.md) + - [UnitPropertyStub](docs/UnitPropertyStub.md) - [UnitStub](docs/UnitStub.md) diff --git a/crates/rocie-client/docs/ApiGetUnitPropertyApi.md b/crates/rocie-client/docs/ApiGetUnitPropertyApi.md new file mode 100644 index 0000000..e59d876 --- /dev/null +++ b/crates/rocie-client/docs/ApiGetUnitPropertyApi.md @@ -0,0 +1,63 @@ +# \ApiGetUnitPropertyApi + +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**unit_properties**](ApiGetUnitPropertyApi.md#unit_properties) | **GET** /unit-properties/ | Return all registered unit properties +[**unit_property_by_id**](ApiGetUnitPropertyApi.md#unit_property_by_id) | **GET** /unit-property/{id} | Get Unit property by id + + + +## unit_properties + +> Vec<models::UnitProperty> unit_properties() +Return all registered unit properties + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**Vec<models::UnitProperty>**](UnitProperty.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json, text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## unit_property_by_id + +> models::UnitProperty unit_property_by_id(id) +Get Unit property by id + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**id** | [**UnitPropertyId**](.md) | Unit Property id | [required] | + +### Return type + +[**models::UnitProperty**](UnitProperty.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json, text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/rocie-client/docs/ApiSetUnitPropertyApi.md b/crates/rocie-client/docs/ApiSetUnitPropertyApi.md new file mode 100644 index 0000000..b54aec1 --- /dev/null +++ b/crates/rocie-client/docs/ApiSetUnitPropertyApi.md @@ -0,0 +1,37 @@ +# \ApiSetUnitPropertyApi + +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**register_unit_property**](ApiSetUnitPropertyApi.md#register_unit_property) | **POST** /unit-property/new | Register an Unit Property + + + +## register_unit_property + +> models::UnitPropertyId register_unit_property(unit_property_stub) +Register an Unit Property + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**unit_property_stub** | [**UnitPropertyStub**](UnitPropertyStub.md) | | [required] | + +### Return type + +[**models::UnitPropertyId**](UnitPropertyId.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json, text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/rocie-client/docs/Product.md b/crates/rocie-client/docs/Product.md index 6f0f914..3de03ae 100644 --- a/crates/rocie-client/docs/Product.md +++ b/crates/rocie-client/docs/Product.md @@ -4,10 +4,11 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**associated_bar_codes** | [**Vec<models::Barcode>**](Barcode.md) | | -**description** | Option<**String**> | | [optional] -**id** | [**models::ProductId**](ProductId.md) | | -**name** | **String** | | +**associated_bar_codes** | [**Vec<models::Barcode>**](Barcode.md) | Which barcodes are associated with this product. | +**description** | Option<**String**> | An optional description of this product. | [optional] +**id** | [**models::ProductId**](ProductId.md) | The id of the product. | +**name** | **String** | The name of the product. This should be globally unique, to make searching easier for the user. | +**unit_property** | [**models::UnitPropertyId**](UnitPropertyId.md) | The property this product is measured in. (This is probably always either Mass, Volume or Quantity). | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/crates/rocie-client/docs/ProductStub.md b/crates/rocie-client/docs/ProductStub.md index 4d4ffde..8bed531 100644 --- a/crates/rocie-client/docs/ProductStub.md +++ b/crates/rocie-client/docs/ProductStub.md @@ -4,9 +4,10 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**description** | Option<**String**> | | [optional] -**name** | **String** | | -**parent** | Option<[**models::ProductId**](ProductId.md)> | | [optional] +**description** | Option<**String**> | A description. | [optional] +**name** | **String** | The name of the product | +**parent** | Option<[**models::ProductId**](ProductId.md)> | A parent of this product, otherwise the parent will be the root of the parent tree. | [optional] +**unit_property** | [**models::UnitPropertyId**](UnitPropertyId.md) | The Unit Property to use for this product. | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/crates/rocie-client/docs/Unit.md b/crates/rocie-client/docs/Unit.md index 5e86ab3..5349b7a 100644 --- a/crates/rocie-client/docs/Unit.md +++ b/crates/rocie-client/docs/Unit.md @@ -4,11 +4,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**description** | Option<**String**> | | [optional] -**full_name_plural** | **String** | | -**full_name_singular** | **String** | | -**id** | [**models::UnitId**](UnitId.md) | | -**short_name** | **String** | | +**description** | Option<**String**> | Description of this unit. | [optional] +**full_name_plural** | **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 | +**full_name_singular** | **String** | The singular version of this unit's name. E.g.: Kilogram Gram | +**id** | [**models::UnitId**](UnitId.md) | Unique id for this unit. | +**short_name** | **String** | Short name or abbreviation of this unit. E.g.: kg for Kilogram g for gram m for meter | +**unit_property** | [**models::UnitPropertyId**](UnitPropertyId.md) | Which property is described by this unit. E.g.: kg -> Mass L -> Volume m/s -> Speed and so forth | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/crates/rocie-client/docs/UnitProperty.md b/crates/rocie-client/docs/UnitProperty.md new file mode 100644 index 0000000..b560f0c --- /dev/null +++ b/crates/rocie-client/docs/UnitProperty.md @@ -0,0 +1,14 @@ +# UnitProperty + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**description** | Option<**String**> | An description of this property. | [optional] +**id** | [**models::UnitPropertyId**](UnitPropertyId.md) | The unique ID for this unit property. | +**name** | **String** | The user-displayed name of this property. | +**units** | [**Vec<models::UnitId>**](UnitId.md) | The units with are measuring this property. | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/rocie-client/docs/UnitPropertyId.md b/crates/rocie-client/docs/UnitPropertyId.md new file mode 100644 index 0000000..34d572f --- /dev/null +++ b/crates/rocie-client/docs/UnitPropertyId.md @@ -0,0 +1,11 @@ +# UnitPropertyId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**value** | [**uuid::Uuid**](uuid::Uuid.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/rocie-client/docs/UnitPropertyStub.md b/crates/rocie-client/docs/UnitPropertyStub.md new file mode 100644 index 0000000..8f6bcbe --- /dev/null +++ b/crates/rocie-client/docs/UnitPropertyStub.md @@ -0,0 +1,12 @@ +# UnitPropertyStub + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**description** | Option<**String**> | | [optional] +**name** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/rocie-client/docs/UnitStub.md b/crates/rocie-client/docs/UnitStub.md index 62ab220..92398c5 100644 --- a/crates/rocie-client/docs/UnitStub.md +++ b/crates/rocie-client/docs/UnitStub.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **full_name_plural** | **String** | | **full_name_singular** | **String** | | **short_name** | **String** | | +**unit_property** | [**models::UnitPropertyId**](UnitPropertyId.md) | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/crates/rocie-client/src/apis/api_get_inventory_api.rs b/crates/rocie-client/src/apis/api_get_inventory_api.rs index 965d3e3..e11fc7f 100644 --- a/crates/rocie-client/src/apis/api_get_inventory_api.rs +++ b/crates/rocie-client/src/apis/api_get_inventory_api.rs @@ -1,7 +1,7 @@ /* * rocie-server * - * An enterprise grocery management system + * An enterprise grocery management system - server * * The version of the OpenAPI document: 0.1.0 * Contact: benedikt.peetz@b-peetz.de 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 88c680b..481084b 100644 --- a/crates/rocie-client/src/apis/api_get_product_api.rs +++ b/crates/rocie-client/src/apis/api_get_product_api.rs @@ -1,7 +1,7 @@ /* * rocie-server * - * An enterprise grocery management system + * An enterprise grocery management system - server * * The version of the OpenAPI document: 0.1.0 * Contact: benedikt.peetz@b-peetz.de 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 81d772b..927b883 100644 --- a/crates/rocie-client/src/apis/api_get_unit_api.rs +++ b/crates/rocie-client/src/apis/api_get_unit_api.rs @@ -1,7 +1,7 @@ /* * rocie-server * - * An enterprise grocery management system + * An enterprise grocery management system - server * * The version of the OpenAPI document: 0.1.0 * Contact: benedikt.peetz@b-peetz.de diff --git a/crates/rocie-client/src/apis/api_get_unit_property_api.rs b/crates/rocie-client/src/apis/api_get_unit_property_api.rs new file mode 100644 index 0000000..1082dcb --- /dev/null +++ b/crates/rocie-client/src/apis/api_get_unit_property_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 [`unit_properties`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UnitPropertiesError { + 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 { + 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_set_barcode_api.rs b/crates/rocie-client/src/apis/api_set_barcode_api.rs index e3ac9fb..5111b6b 100644 --- a/crates/rocie-client/src/apis/api_set_barcode_api.rs +++ b/crates/rocie-client/src/apis/api_set_barcode_api.rs @@ -1,7 +1,7 @@ /* * rocie-server * - * An enterprise grocery management system + * An enterprise grocery management system - server * * The version of the OpenAPI document: 0.1.0 * Contact: benedikt.peetz@b-peetz.de diff --git a/crates/rocie-client/src/apis/api_set_product_api.rs b/crates/rocie-client/src/apis/api_set_product_api.rs index d3cf378..b2d65a3 100644 --- a/crates/rocie-client/src/apis/api_set_product_api.rs +++ b/crates/rocie-client/src/apis/api_set_product_api.rs @@ -1,7 +1,7 @@ /* * rocie-server * - * An enterprise grocery management system + * An enterprise grocery management system - server * * The version of the OpenAPI document: 0.1.0 * Contact: benedikt.peetz@b-peetz.de diff --git a/crates/rocie-client/src/apis/api_set_unit_api.rs b/crates/rocie-client/src/apis/api_set_unit_api.rs index dc88775..1c64bfb 100644 --- a/crates/rocie-client/src/apis/api_set_unit_api.rs +++ b/crates/rocie-client/src/apis/api_set_unit_api.rs @@ -1,7 +1,7 @@ /* * rocie-server * - * An enterprise grocery management system + * An enterprise grocery management system - server * * The version of the OpenAPI document: 0.1.0 * Contact: benedikt.peetz@b-peetz.de diff --git a/crates/rocie-client/src/apis/api_set_unit_property_api.rs b/crates/rocie-client/src/apis/api_set_unit_property_api.rs new file mode 100644 index 0000000..35398bc --- /dev/null +++ b/crates/rocie-client/src/apis/api_set_unit_property_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_unit_property`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RegisterUnitPropertyError { + 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/configuration.rs b/crates/rocie-client/src/apis/configuration.rs index a4fbb93..590f233 100644 --- a/crates/rocie-client/src/apis/configuration.rs +++ b/crates/rocie-client/src/apis/configuration.rs @@ -1,7 +1,7 @@ /* * rocie-server * - * An enterprise grocery management system + * An enterprise grocery management system - server * * The version of the OpenAPI document: 0.1.0 * Contact: benedikt.peetz@b-peetz.de diff --git a/crates/rocie-client/src/apis/mod.rs b/crates/rocie-client/src/apis/mod.rs index be88193..0853432 100644 --- a/crates/rocie-client/src/apis/mod.rs +++ b/crates/rocie-client/src/apis/mod.rs @@ -114,8 +114,10 @@ impl From<&str> for ContentType { pub mod api_get_inventory_api; pub mod api_get_product_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_unit_api; +pub mod api_set_unit_property_api; pub mod configuration; diff --git a/crates/rocie-client/src/implies.rs b/crates/rocie-client/src/implies.rs index 147588a..382b8ca 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}; +use crate::models::{BarcodeId, ProductId, UnitId, UnitPropertyId}; // TODO(@bpeetz): The client generator should just do this. <2025-09-23> @@ -24,3 +24,10 @@ impl Display for UnitId { } } impl Copy for UnitId {} + +impl Display for UnitPropertyId { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.value.fmt(f) + } +} +impl Copy for UnitPropertyId {} diff --git a/crates/rocie-client/src/models/barcode.rs b/crates/rocie-client/src/models/barcode.rs index 76661dc..f44caa9 100644 --- a/crates/rocie-client/src/models/barcode.rs +++ b/crates/rocie-client/src/models/barcode.rs @@ -1,7 +1,7 @@ /* * rocie-server * - * An enterprise grocery management system + * An enterprise grocery management system - server * * The version of the OpenAPI document: 0.1.0 * Contact: benedikt.peetz@b-peetz.de diff --git a/crates/rocie-client/src/models/barcode_id.rs b/crates/rocie-client/src/models/barcode_id.rs index 2bd4775..a081913 100644 --- a/crates/rocie-client/src/models/barcode_id.rs +++ b/crates/rocie-client/src/models/barcode_id.rs @@ -1,7 +1,7 @@ /* * rocie-server * - * An enterprise grocery management system + * An enterprise grocery management system - server * * The version of the OpenAPI document: 0.1.0 * Contact: benedikt.peetz@b-peetz.de diff --git a/crates/rocie-client/src/models/mod.rs b/crates/rocie-client/src/models/mod.rs index 6456de7..4eabdfc 100644 --- a/crates/rocie-client/src/models/mod.rs +++ b/crates/rocie-client/src/models/mod.rs @@ -16,5 +16,11 @@ pub mod unit_amount; pub use self::unit_amount::UnitAmount; pub mod unit_id; pub use self::unit_id::UnitId; +pub mod unit_property; +pub use self::unit_property::UnitProperty; +pub mod unit_property_id; +pub use self::unit_property_id::UnitPropertyId; +pub mod unit_property_stub; +pub use self::unit_property_stub::UnitPropertyStub; pub mod unit_stub; pub use self::unit_stub::UnitStub; diff --git a/crates/rocie-client/src/models/product.rs b/crates/rocie-client/src/models/product.rs index 8fe68ee..251046c 100644 --- a/crates/rocie-client/src/models/product.rs +++ b/crates/rocie-client/src/models/product.rs @@ -1,7 +1,7 @@ /* * rocie-server * - * An enterprise grocery management system + * An enterprise grocery management system - server * * The version of the OpenAPI document: 0.1.0 * Contact: benedikt.peetz@b-peetz.de @@ -11,25 +11,35 @@ use crate::models; use serde::{Deserialize, Serialize}; +/// Product : The base of rocie. Products can be bought and consumed and represent, what you actually have in storage. Not every product is bought, as some can also be obtained by cooking a recipe. #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Product { + /// Which barcodes are associated with this 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>>, + /// 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 property this product is measured in. (This is probably always either Mass, Volume or Quantity). + #[serde(rename = "unit_property")] + pub unit_property: models::UnitPropertyId, } impl Product { - pub fn new(associated_bar_codes: Vec<models::Barcode>, id: models::ProductId, name: String) -> Product { + /// The base of rocie. Products can be bought and consumed and represent, what you actually have in storage. Not every product is bought, as some can also be obtained by cooking a recipe. + pub fn new(associated_bar_codes: Vec<models::Barcode>, id: models::ProductId, name: String, unit_property: models::UnitPropertyId) -> Product { Product { associated_bar_codes, description: None, id, name, + unit_property, } } } diff --git a/crates/rocie-client/src/models/product_amount.rs b/crates/rocie-client/src/models/product_amount.rs index 1a2ed02..43ab725 100644 --- a/crates/rocie-client/src/models/product_amount.rs +++ b/crates/rocie-client/src/models/product_amount.rs @@ -1,7 +1,7 @@ /* * rocie-server * - * An enterprise grocery management system + * An enterprise grocery management system - server * * The version of the OpenAPI document: 0.1.0 * Contact: benedikt.peetz@b-peetz.de diff --git a/crates/rocie-client/src/models/product_id.rs b/crates/rocie-client/src/models/product_id.rs index 021bd38..0f65bb8 100644 --- a/crates/rocie-client/src/models/product_id.rs +++ b/crates/rocie-client/src/models/product_id.rs @@ -1,7 +1,7 @@ /* * rocie-server * - * An enterprise grocery management system + * An enterprise grocery management system - server * * The version of the OpenAPI document: 0.1.0 * Contact: benedikt.peetz@b-peetz.de diff --git a/crates/rocie-client/src/models/product_stub.rs b/crates/rocie-client/src/models/product_stub.rs index 40c1123..0328076 100644 --- a/crates/rocie-client/src/models/product_stub.rs +++ b/crates/rocie-client/src/models/product_stub.rs @@ -1,7 +1,7 @@ /* * rocie-server * - * An enterprise grocery management system + * An enterprise grocery management system - server * * The version of the OpenAPI document: 0.1.0 * Contact: benedikt.peetz@b-peetz.de @@ -13,20 +13,27 @@ 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>>, + /// 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>>, + /// The Unit Property to use for this product. + #[serde(rename = "unit_property")] + pub unit_property: models::UnitPropertyId, } impl ProductStub { - pub fn new(name: String) -> ProductStub { + pub fn new(name: String, unit_property: models::UnitPropertyId) -> ProductStub { ProductStub { description: None, name, parent: None, + unit_property, } } } diff --git a/crates/rocie-client/src/models/unit.rs b/crates/rocie-client/src/models/unit.rs index 760d532..6361a1c 100644 --- a/crates/rocie-client/src/models/unit.rs +++ b/crates/rocie-client/src/models/unit.rs @@ -1,7 +1,7 @@ /* * rocie-server * - * An enterprise grocery management system + * An enterprise grocery management system - server * * The version of the OpenAPI document: 0.1.0 * Contact: benedikt.peetz@b-peetz.de @@ -13,26 +13,35 @@ 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>>, + /// 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, + /// The singular version of this unit's name. E.g.: Kilogram Gram #[serde(rename = "full_name_singular")] pub full_name_singular: String, + /// Unique id for this unit. #[serde(rename = "id")] pub id: models::UnitId, + /// Short name or abbreviation of this unit. E.g.: kg for Kilogram g for gram m for meter #[serde(rename = "short_name")] pub short_name: String, + /// Which property is described by this unit. E.g.: kg -> Mass L -> Volume m/s -> Speed and so forth + #[serde(rename = "unit_property")] + pub unit_property: models::UnitPropertyId, } impl Unit { - pub fn new(full_name_plural: String, full_name_singular: String, id: models::UnitId, short_name: String) -> Unit { + pub fn new(full_name_plural: String, full_name_singular: String, id: models::UnitId, short_name: String, unit_property: models::UnitPropertyId) -> Unit { Unit { description: None, full_name_plural, full_name_singular, id, short_name, + unit_property, } } } diff --git a/crates/rocie-client/src/models/unit_amount.rs b/crates/rocie-client/src/models/unit_amount.rs index 928a6f4..e4b1a54 100644 --- a/crates/rocie-client/src/models/unit_amount.rs +++ b/crates/rocie-client/src/models/unit_amount.rs @@ -1,7 +1,7 @@ /* * rocie-server * - * An enterprise grocery management system + * An enterprise grocery management system - server * * The version of the OpenAPI document: 0.1.0 * Contact: benedikt.peetz@b-peetz.de diff --git a/crates/rocie-client/src/models/unit_id.rs b/crates/rocie-client/src/models/unit_id.rs index ea1ef51..8b08d95 100644 --- a/crates/rocie-client/src/models/unit_id.rs +++ b/crates/rocie-client/src/models/unit_id.rs @@ -1,7 +1,7 @@ /* * rocie-server * - * An enterprise grocery management system + * An enterprise grocery management system - server * * The version of the OpenAPI document: 0.1.0 * Contact: benedikt.peetz@b-peetz.de diff --git a/crates/rocie-client/src/models/unit_property.rs b/crates/rocie-client/src/models/unit_property.rs new file mode 100644 index 0000000..f62012b --- /dev/null +++ b/crates/rocie-client/src/models/unit_property.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}; + +/// UnitProperty : An unit property describes a property that can be measured by units. For example velocity, mass or volume. +#[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>>, + /// The unique ID for this unit property. + #[serde(rename = "id")] + pub id: models::UnitPropertyId, + /// The user-displayed name of this property. + #[serde(rename = "name")] + pub name: String, + /// The units with are measuring this property. + #[serde(rename = "units")] + pub units: Vec<models::UnitId>, +} + +impl UnitProperty { + /// An unit property describes a property that can be measured by units. For example velocity, mass or volume. + pub fn new(id: models::UnitPropertyId, name: String, units: Vec<models::UnitId>) -> UnitProperty { + UnitProperty { + description: None, + id, + name, + units, + } + } +} + diff --git a/crates/rocie-client/src/models/unit_property_id.rs b/crates/rocie-client/src/models/unit_property_id.rs new file mode 100644 index 0000000..aca567c --- /dev/null +++ b/crates/rocie-client/src/models/unit_property_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 UnitPropertyId { + #[serde(rename = "value")] + pub value: uuid::Uuid, +} + +impl UnitPropertyId { + pub fn new(value: uuid::Uuid) -> UnitPropertyId { + UnitPropertyId { + value, + } + } +} + diff --git a/crates/rocie-client/src/models/unit_property_stub.rs b/crates/rocie-client/src/models/unit_property_stub.rs new file mode 100644 index 0000000..be2d31e --- /dev/null +++ b/crates/rocie-client/src/models/unit_property_stub.rs @@ -0,0 +1,30 @@ +/* + * 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 UnitPropertyStub { + #[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub description: Option<Option<String>>, + #[serde(rename = "name")] + pub name: String, +} + +impl UnitPropertyStub { + pub fn new(name: String) -> UnitPropertyStub { + UnitPropertyStub { + description: None, + name, + } + } +} + diff --git a/crates/rocie-client/src/models/unit_stub.rs b/crates/rocie-client/src/models/unit_stub.rs index 03f81fd..aafad6c 100644 --- a/crates/rocie-client/src/models/unit_stub.rs +++ b/crates/rocie-client/src/models/unit_stub.rs @@ -1,7 +1,7 @@ /* * rocie-server * - * An enterprise grocery management system + * An enterprise grocery management system - server * * The version of the OpenAPI document: 0.1.0 * Contact: benedikt.peetz@b-peetz.de @@ -21,15 +21,18 @@ pub struct UnitStub { pub full_name_singular: String, #[serde(rename = "short_name")] pub short_name: String, + #[serde(rename = "unit_property")] + pub unit_property: models::UnitPropertyId, } impl UnitStub { - pub fn new(full_name_plural: String, full_name_singular: String, short_name: String) -> UnitStub { + pub fn new(full_name_plural: String, full_name_singular: String, short_name: String, unit_property: models::UnitPropertyId) -> UnitStub { UnitStub { description: None, full_name_plural, full_name_singular, short_name, + unit_property, } } } |
