diff options
Diffstat (limited to 'crates/rocie-client')
38 files changed, 1270 insertions, 27 deletions
diff --git a/crates/rocie-client/.openapi-generator/FILES b/crates/rocie-client/.openapi-generator/FILES index 053b1f2..cf7a068 100644 --- a/crates/rocie-client/.openapi-generator/FILES +++ b/crates/rocie-client/.openapi-generator/FILES @@ -3,10 +3,14 @@ README.md docs/ApiGetInventoryApi.md docs/ApiGetProductApi.md +docs/ApiGetProductParentApi.md +docs/ApiGetRecipeApi.md docs/ApiGetUnitApi.md docs/ApiGetUnitPropertyApi.md docs/ApiSetBarcodeApi.md docs/ApiSetProductApi.md +docs/ApiSetProductParentApi.md +docs/ApiSetRecipeApi.md docs/ApiSetUnitApi.md docs/ApiSetUnitPropertyApi.md docs/Barcode.md @@ -14,7 +18,13 @@ docs/BarcodeId.md docs/Product.md docs/ProductAmount.md docs/ProductId.md +docs/ProductParent.md +docs/ProductParentId.md +docs/ProductParentStub.md docs/ProductStub.md +docs/Recipe.md +docs/RecipeId.md +docs/RecipeStub.md docs/Unit.md docs/UnitAmount.md docs/UnitId.md @@ -25,10 +35,14 @@ docs/UnitStub.md git_push.sh src/apis/api_get_inventory_api.rs src/apis/api_get_product_api.rs +src/apis/api_get_product_parent_api.rs +src/apis/api_get_recipe_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_product_parent_api.rs +src/apis/api_set_recipe_api.rs src/apis/api_set_unit_api.rs src/apis/api_set_unit_property_api.rs src/apis/configuration.rs @@ -39,7 +53,13 @@ src/models/mod.rs src/models/product.rs src/models/product_amount.rs src/models/product_id.rs +src/models/product_parent.rs +src/models/product_parent_id.rs +src/models/product_parent_stub.rs src/models/product_stub.rs +src/models/recipe.rs +src/models/recipe_id.rs +src/models/recipe_stub.rs src/models/unit.rs src/models/unit_amount.rs src/models/unit_id.rs diff --git a/crates/rocie-client/README.md b/crates/rocie-client/README.md index ae0cbff..e25385a 100644 --- a/crates/rocie-client/README.md +++ b/crates/rocie-client/README.md @@ -30,15 +30,26 @@ Class | Method | HTTP request | Description *ApiGetProductApi* | [**product_by_id**](docs/ApiGetProductApi.md#product_by_id) | **GET** /product/by-id/{id} | Get Product by id *ApiGetProductApi* | [**product_by_name**](docs/ApiGetProductApi.md#product_by_name) | **GET** /product/by-name/{name} | Get Product by name *ApiGetProductApi* | [**product_suggestion_by_name**](docs/ApiGetProductApi.md#product_suggestion_by_name) | **GET** /product/by-part-name/{name} | Get Product suggestion by name -*ApiGetProductApi* | [**products**](docs/ApiGetProductApi.md#products) | **GET** /products/ | Return all registered products +*ApiGetProductApi* | [**products_by_product_parent_id_direct**](docs/ApiGetProductApi.md#products_by_product_parent_id_direct) | **GET** /product/by-product-parent-id-direct/{id} | Get Products by it's product parent id +*ApiGetProductApi* | [**products_by_product_parent_id_indirect**](docs/ApiGetProductApi.md#products_by_product_parent_id_indirect) | **GET** /product/by-product-parent-id-indirect/{id} | Get Products by it's product parent id +*ApiGetProductApi* | [**products_in_storage**](docs/ApiGetProductApi.md#products_in_storage) | **GET** /products_in_storage/ | Return all products, which non-null amount in storage +*ApiGetProductApi* | [**products_registered**](docs/ApiGetProductApi.md#products_registered) | **GET** /products_registered/ | Return all registered products +*ApiGetProductParentApi* | [**product_parents**](docs/ApiGetProductParentApi.md#product_parents) | **GET** /product_parents/ | Return all registered product parents +*ApiGetProductParentApi* | [**product_parents_toplevel**](docs/ApiGetProductParentApi.md#product_parents_toplevel) | **GET** /product_parents_toplevel/ | Return all registered product parents, that have no parents themselves +*ApiGetProductParentApi* | [**product_parents_under**](docs/ApiGetProductParentApi.md#product_parents_under) | **GET** /product_parents_under/{id} | Return all parents, that have this parent as parent +*ApiGetRecipeApi* | [**recipe_by_id**](docs/ApiGetRecipeApi.md#recipe_by_id) | **GET** /recipe/by-id/{id} | Get an recipe by it's id. +*ApiGetRecipeApi* | [**recipes**](docs/ApiGetRecipeApi.md#recipes) | **GET** /recipe/all | Get all added recipes *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 +*ApiGetUnitApi* | [**units_by_property_id**](docs/ApiGetUnitApi.md#units_by_property_id) | **GET** /units-by-property/{id} | Return all registered units for a specific unit property *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/{barcode_id}/buy/{times} | 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 +*ApiSetProductParentApi* | [**register_product_parent**](docs/ApiSetProductParentApi.md#register_product_parent) | **POST** /product_parent/new | Register a product parent +*ApiSetRecipeApi* | [**add_recipe**](docs/ApiSetRecipeApi.md#add_recipe) | **POST** /recipe/new | Register a product parent *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 @@ -50,7 +61,13 @@ Class | Method | HTTP request | Description - [Product](docs/Product.md) - [ProductAmount](docs/ProductAmount.md) - [ProductId](docs/ProductId.md) + - [ProductParent](docs/ProductParent.md) + - [ProductParentId](docs/ProductParentId.md) + - [ProductParentStub](docs/ProductParentStub.md) - [ProductStub](docs/ProductStub.md) + - [Recipe](docs/Recipe.md) + - [RecipeId](docs/RecipeId.md) + - [RecipeStub](docs/RecipeStub.md) - [Unit](docs/Unit.md) - [UnitAmount](docs/UnitAmount.md) - [UnitId](docs/UnitId.md) diff --git a/crates/rocie-client/docs/ApiGetProductApi.md b/crates/rocie-client/docs/ApiGetProductApi.md index a7d0918..3491910 100644 --- a/crates/rocie-client/docs/ApiGetProductApi.md +++ b/crates/rocie-client/docs/ApiGetProductApi.md @@ -7,7 +7,10 @@ Method | HTTP request | Description [**product_by_id**](ApiGetProductApi.md#product_by_id) | **GET** /product/by-id/{id} | Get Product by id [**product_by_name**](ApiGetProductApi.md#product_by_name) | **GET** /product/by-name/{name} | Get Product by name [**product_suggestion_by_name**](ApiGetProductApi.md#product_suggestion_by_name) | **GET** /product/by-part-name/{name} | Get Product suggestion by name -[**products**](ApiGetProductApi.md#products) | **GET** /products/ | Return all registered products +[**products_by_product_parent_id_direct**](ApiGetProductApi.md#products_by_product_parent_id_direct) | **GET** /product/by-product-parent-id-direct/{id} | Get Products by it's product parent id +[**products_by_product_parent_id_indirect**](ApiGetProductApi.md#products_by_product_parent_id_indirect) | **GET** /product/by-product-parent-id-indirect/{id} | Get Products by it's product parent id +[**products_in_storage**](ApiGetProductApi.md#products_in_storage) | **GET** /products_in_storage/ | Return all products, which non-null amount in storage +[**products_registered**](ApiGetProductApi.md#products_registered) | **GET** /products_registered/ | Return all registered products @@ -95,9 +98,94 @@ No authorization required [[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) -## products +## products_by_product_parent_id_direct -> Vec<models::Product> products() +> Vec<models::Product> products_by_product_parent_id_direct(id) +Get Products by it's product parent id + +This will only return products directly associated with this product parent id + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**id** | [**ProductParentId**](.md) | Product parent id | [required] | + +### Return type + +[**Vec<models::Product>**](Product.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) + + +## products_by_product_parent_id_indirect + +> Vec<models::Product> products_by_product_parent_id_indirect(id) +Get Products by it's product parent id + +This will also return all products below this product parent id + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**id** | [**ProductParentId**](.md) | Product parent id | [required] | + +### Return type + +[**Vec<models::Product>**](Product.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) + + +## products_in_storage + +> Vec<models::Product> products_in_storage() +Return all products, which non-null amount in storage + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**Vec<models::Product>**](Product.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) + + +## products_registered + +> Vec<models::Product> products_registered() Return all registered products ### Parameters diff --git a/crates/rocie-client/docs/ApiGetProductParentApi.md b/crates/rocie-client/docs/ApiGetProductParentApi.md new file mode 100644 index 0000000..3c61982 --- /dev/null +++ b/crates/rocie-client/docs/ApiGetProductParentApi.md @@ -0,0 +1,89 @@ +# \ApiGetProductParentApi + +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**product_parents**](ApiGetProductParentApi.md#product_parents) | **GET** /product_parents/ | Return all registered product parents +[**product_parents_toplevel**](ApiGetProductParentApi.md#product_parents_toplevel) | **GET** /product_parents_toplevel/ | Return all registered product parents, that have no parents themselves +[**product_parents_under**](ApiGetProductParentApi.md#product_parents_under) | **GET** /product_parents_under/{id} | Return all parents, that have this parent as parent + + + +## product_parents + +> Vec<models::ProductParent> product_parents() +Return all registered product parents + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**Vec<models::ProductParent>**](ProductParent.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) + + +## product_parents_toplevel + +> Vec<models::ProductParent> product_parents_toplevel() +Return all registered product parents, that have no parents themselves + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**Vec<models::ProductParent>**](ProductParent.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) + + +## product_parents_under + +> Vec<models::ProductParent> product_parents_under(id) +Return all parents, that have this parent as parent + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**id** | [**ProductParentId**](.md) | Product parent id | [required] | + +### Return type + +[**Vec<models::ProductParent>**](ProductParent.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/ApiGetRecipeApi.md b/crates/rocie-client/docs/ApiGetRecipeApi.md new file mode 100644 index 0000000..cce6112 --- /dev/null +++ b/crates/rocie-client/docs/ApiGetRecipeApi.md @@ -0,0 +1,63 @@ +# \ApiGetRecipeApi + +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**recipe_by_id**](ApiGetRecipeApi.md#recipe_by_id) | **GET** /recipe/by-id/{id} | Get an recipe by it's id. +[**recipes**](ApiGetRecipeApi.md#recipes) | **GET** /recipe/all | Get all added recipes + + + +## recipe_by_id + +> models::Recipe recipe_by_id(id) +Get an recipe by it's id. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**id** | [**RecipeId**](.md) | Recipe id | [required] | + +### Return type + +[**models::Recipe**](Recipe.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) + + +## recipes + +> models::Recipe recipes() +Get all added recipes + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**models::Recipe**](Recipe.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/ApiGetUnitApi.md b/crates/rocie-client/docs/ApiGetUnitApi.md index f539aec..f2fc6e6 100644 --- a/crates/rocie-client/docs/ApiGetUnitApi.md +++ b/crates/rocie-client/docs/ApiGetUnitApi.md @@ -6,6 +6,7 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**unit_by_id**](ApiGetUnitApi.md#unit_by_id) | **GET** /unit/{id} | Get Unit by id [**units**](ApiGetUnitApi.md#units) | **GET** /units/ | Return all registered units +[**units_by_property_id**](ApiGetUnitApi.md#units_by_property_id) | **GET** /units-by-property/{id} | Return all registered units for a specific unit property @@ -61,3 +62,31 @@ No authorization required [[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) + +## units_by_property_id + +> Vec<models::Unit> units_by_property_id(id) +Return all registered units for a specific unit property + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**id** | [**UnitPropertyId**](.md) | Unit property id | [required] | + +### Return type + +[**Vec<models::Unit>**](Unit.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/ApiSetProductParentApi.md b/crates/rocie-client/docs/ApiSetProductParentApi.md new file mode 100644 index 0000000..116175c --- /dev/null +++ b/crates/rocie-client/docs/ApiSetProductParentApi.md @@ -0,0 +1,37 @@ +# \ApiSetProductParentApi + +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**register_product_parent**](ApiSetProductParentApi.md#register_product_parent) | **POST** /product_parent/new | Register a product parent + + + +## register_product_parent + +> models::ProductParentId register_product_parent(product_parent_stub) +Register a product parent + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**product_parent_stub** | [**ProductParentStub**](ProductParentStub.md) | | [required] | + +### Return type + +[**models::ProductParentId**](ProductParentId.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/ApiSetRecipeApi.md b/crates/rocie-client/docs/ApiSetRecipeApi.md new file mode 100644 index 0000000..00f2670 --- /dev/null +++ b/crates/rocie-client/docs/ApiSetRecipeApi.md @@ -0,0 +1,37 @@ +# \ApiSetRecipeApi + +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**add_recipe**](ApiSetRecipeApi.md#add_recipe) | **POST** /recipe/new | Register a product parent + + + +## add_recipe + +> models::RecipeId add_recipe(recipe_stub) +Register a product parent + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**recipe_stub** | [**RecipeStub**](RecipeStub.md) | | [required] | + +### Return type + +[**models::RecipeId**](RecipeId.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 3de03ae..83536ff 100644 --- a/crates/rocie-client/docs/Product.md +++ b/crates/rocie-client/docs/Product.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **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. | +**parent** | Option<[**models::ProductParentId**](ProductParentId.md)> | The parent this product has. This is effectively it's anchor in the product DAG. | [optional] **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/ProductParent.md b/crates/rocie-client/docs/ProductParent.md new file mode 100644 index 0000000..a63384b --- /dev/null +++ b/crates/rocie-client/docs/ProductParent.md @@ -0,0 +1,14 @@ +# ProductParent + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**description** | Option<**String**> | An optional description of this product parent. | [optional] +**id** | [**models::ProductParentId**](ProductParentId.md) | The id of the product parent. | +**name** | **String** | The name of the product parent. This should be globally unique, to make searching easier for the user. | +**parent** | Option<[**models::ProductParentId**](ProductParentId.md)> | The optional id of the parent of this product parent. This must not form a cycle. | [optional] + +[[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/ProductParentId.md b/crates/rocie-client/docs/ProductParentId.md new file mode 100644 index 0000000..c9163f4 --- /dev/null +++ b/crates/rocie-client/docs/ProductParentId.md @@ -0,0 +1,11 @@ +# ProductParentId + +## 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/ProductParentStub.md b/crates/rocie-client/docs/ProductParentStub.md new file mode 100644 index 0000000..c15118e --- /dev/null +++ b/crates/rocie-client/docs/ProductParentStub.md @@ -0,0 +1,13 @@ +# ProductParentStub + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**description** | Option<**String**> | A description. | [optional] +**name** | **String** | The name of the product parent | +**parent** | Option<[**models::ProductParentId**](ProductParentId.md)> | A parent of this product parent, otherwise the parent will be the root of the parent tree. | [optional] + +[[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 8bed531..10d783b 100644 --- a/crates/rocie-client/docs/ProductStub.md +++ b/crates/rocie-client/docs/ProductStub.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **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] +**parent** | Option<[**models::ProductParentId**](ProductParentId.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/Recipe.md b/crates/rocie-client/docs/Recipe.md new file mode 100644 index 0000000..d179f97 --- /dev/null +++ b/crates/rocie-client/docs/Recipe.md @@ -0,0 +1,13 @@ +# Recipe + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**content** | **String** | | +**id** | [**models::RecipeId**](RecipeId.md) | | +**path** | **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/RecipeId.md b/crates/rocie-client/docs/RecipeId.md new file mode 100644 index 0000000..5211596 --- /dev/null +++ b/crates/rocie-client/docs/RecipeId.md @@ -0,0 +1,11 @@ +# RecipeId + +## 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/RecipeStub.md b/crates/rocie-client/docs/RecipeStub.md new file mode 100644 index 0000000..4545fff --- /dev/null +++ b/crates/rocie-client/docs/RecipeStub.md @@ -0,0 +1,12 @@ +# RecipeStub + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**content** | **String** | The content of this recipe, in cooklang format | +**path** | **String** | The path the recipe should have | + +[[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 index 8f6bcbe..0fae3f7 100644 --- a/crates/rocie-client/docs/UnitPropertyStub.md +++ b/crates/rocie-client/docs/UnitPropertyStub.md @@ -4,8 +4,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**description** | Option<**String**> | | [optional] -**name** | **String** | | +**description** | Option<**String**> | An optional description of the unit property. | [optional] +**name** | **String** | The name of the unit 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/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")] |
