summaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/api/mod.rs221
1 files changed, 198 insertions, 23 deletions
diff --git a/src/api/mod.rs b/src/api/mod.rs
index 3bc870c..eb9ca3a 100644
--- a/src/api/mod.rs
+++ b/src/api/mod.rs
@@ -1,20 +1,38 @@
use leptos::error::Error;
use rocie_client::{
apis::{
- api_get_inventory_api::amount_by_id,
- api_get_product_api::{
- product_by_id, product_by_name, product_suggestion_by_name, products_in_storage,
- products_registered,
+ api_get_auth_inventory_api::amount_by_id,
+ api_get_auth_product_api::{
+ product_by_id, product_by_name, product_suggestion_by_name,
+ products_by_product_parent_id_direct, products_by_product_parent_id_indirect,
+ products_in_storage, products_registered, products_without_product_parent,
},
- api_get_unit_api::unit_by_id,
- api_get_unit_property_api::{unit_properties, unit_property_by_id},
- api_set_barcode_api::buy_barcode,
- api_set_product_api::{associate_barcode, register_product},
+ api_get_auth_product_parent_api::{
+ product_parents, product_parents_toplevel, product_parents_under,
+ },
+ api_get_auth_recipe_api::{
+ recipe_by_id, recipe_by_name, recipes, recipes_by_recipe_parent_id_direct,
+ recipes_by_recipe_parent_id_indirect, recipes_without_recipe_parent,
+ },
+ api_get_auth_recipe_parent_api::{
+ recipe_parents, recipe_parents_toplevel, recipe_parents_under,
+ },
+ api_get_auth_unit_api::{unit_by_id, units, units_by_property_id},
+ api_get_auth_unit_property_api::{unit_properties, unit_property_by_id},
+ api_get_no_auth_state_api::{can_be_provisioned, is_logged_in},
+ api_set_auth_barcode_api::buy_barcode,
+ api_set_auth_product_api::{associate_barcode, register_product},
+ api_set_auth_product_parent_api::register_product_parent,
+ api_set_auth_recipe_api::add_recipe,
+ api_set_auth_recipe_parent_api::register_recipe_parent,
+ api_set_no_auth_user_api::{login, provision},
configuration::Configuration,
},
models::{
- Barcode, BarcodeId, Product, ProductAmount, ProductId, ProductStub, Unit, UnitId,
- UnitProperty, UnitPropertyId,
+ Barcode, BarcodeId, LoginInfo, Product, ProductAmount, ProductId, ProductParent,
+ ProductParentId, ProductParentStub, ProductStub, ProvisionInfo, Recipe, RecipeId,
+ RecipeParent, RecipeParentId, RecipeParentStub, RecipeStub, Unit, UnitId, UnitProperty,
+ UnitPropertyId, UserId, UserStub,
},
};
@@ -89,22 +107,179 @@ macro_rules! mk_wrapper {
}
}
-mk_wrapper!(product_by_id(product_id: ProductId) -> Product as product_by_id_wrapped);
+mk_wrapper!(
+ is_logged_in() -> bool
+ as is_logged_in_wrapped
+);
+mk_wrapper!(
+ can_be_provisioned() -> bool
+ as can_be_provisioned_wrapped
+);
+
+mk_wrapper!(
+ @external_config
+ login(&config, login_info: LoginInfo) -> ()
+ as login_external_wrapped
+);
+mk_wrapper!(
+ @external_config
+ provision(&config, provsion_info: ProvisionInfo) -> UserId
+ as provision_external_wrapped
+);
+
+mk_wrapper!(
+ product_by_id(product_id: ProductId) -> Product
+ as product_by_id_wrapped
+);
+
+mk_wrapper!(
+ product_by_name(name: &str) -> Product
+ as product_by_name_wrapped
+);
+mk_wrapper!(
+ @treat_404_as_None
+ product_by_name(name: &str) -> Option<Product>
+ as product_by_name_404_wrapped
+);
+mk_wrapper!(
+ @external_config
+ product_by_name(&config, name: &str) -> Product
+ as product_by_name_external_wrapped
+);
+
+mk_wrapper!(
+ product_suggestion_by_name(part_name: &str) -> Vec<Product>
+ as product_suggestion_by_name_wrapped
+);
+
+mk_wrapper!(
+ units() -> Vec<Unit>
+ as units_wrapped
+);
+mk_wrapper!(
+ units_by_property_id(id: UnitPropertyId) -> Vec<Unit>
+ as units_by_property_id_wrapped
+);
+mk_wrapper!(
+ unit_by_id(unit_id: UnitId) -> Unit
+ as unit_by_id_wrapped
+);
+mk_wrapper!(
+ unit_property_by_id(unit_id: UnitPropertyId) -> UnitProperty
+ as unit_property_by_id_wrapped
+);
+mk_wrapper!(
+ unit_properties() -> Vec<UnitProperty>
+ as unit_properties_wrapped
+);
-mk_wrapper!(@treat_404_as_None product_by_name(name: &str) -> Option<Product> as product_by_name_404_wrapped);
-mk_wrapper!(@external_config product_by_name(&config, name: &str) -> Product as product_by_name_external_wrapped);
+mk_wrapper!(
+ @treat_404_as_None
+ amount_by_id(product_id: ProductId) -> Option<ProductAmount>
+ as amount_by_id_404_wrapped
+);
-mk_wrapper!(product_suggestion_by_name(part_name: &str) -> Vec<Product> as product_suggestion_by_name_wrapped);
+mk_wrapper!(
+ products_registered() -> Vec<Product>
+ as products_registered_wrapped
+);
+mk_wrapper!(
+ products_in_storage() -> Vec<Product>
+ as products_in_storage_wrapped
+);
+mk_wrapper!(
+ products_without_product_parent() -> Vec<Product>
+ as products_without_product_parent_wrapped
+);
+mk_wrapper!(
+ products_by_product_parent_id_indirect(product_parent_id: ProductParentId) -> Vec<Product>
+ as products_by_product_parent_id_indirect_wrapped
+);
+mk_wrapper!(
+ products_by_product_parent_id_direct(product_parent_id: ProductParentId) -> Vec<Product>
+ as products_by_product_parent_id_direct_wrapped
+);
-mk_wrapper!(unit_by_id(unit_id: UnitId) -> Unit as unit_by_id_wrapped);
-mk_wrapper!(unit_property_by_id(unit_id: UnitPropertyId) -> UnitProperty as unit_property_by_id_wrapped);
-mk_wrapper!(unit_properties() -> Vec<UnitProperty> as unit_properties_wrapped);
+mk_wrapper!(
+ @external_config
+ register_product_parent(&config, product_parent_stub: ProductParentStub) -> ProductParentId
+ as register_product_parent_external_wrapped
+);
+mk_wrapper!(
+ product_parents_toplevel() -> Vec<ProductParent>
+ as product_parents_toplevel_wrapped
+);
+mk_wrapper!(
+ @treat_404_as_None
+ product_parents_under(id: ProductParentId) -> Option<Vec<ProductParent>>
+ as product_parents_under_404_wrapped
+);
+mk_wrapper!(
+ product_parents() -> Vec<ProductParent>
+ as product_parents_wrapped
+);
-mk_wrapper!(amount_by_id(product_id: ProductId) -> ProductAmount as amount_by_id_wrapped);
+mk_wrapper!(
+ recipes() -> Vec<Recipe>
+ as recipes_wrapped
+);
+mk_wrapper!(
+ recipes_without_recipe_parent() -> Vec<Recipe>
+ as recipes_without_recipe_parent_wrapped
+);
+mk_wrapper!(
+ @external_config
+ add_recipe(&config, stub: RecipeStub) -> RecipeId
+ as add_recipe_external_wrapped
+);
+mk_wrapper!(
+ recipes_by_recipe_parent_id_indirect(recipe_parent_id: RecipeParentId) -> Vec<Recipe>
+ as recipes_by_recipe_parent_id_indirect_wrapped
+);
+mk_wrapper!(
+ recipes_by_recipe_parent_id_direct(recipe_parent_id: RecipeParentId) -> Vec<Recipe>
+ as recipes_by_recipe_parent_id_direct_wrapped
+);
+mk_wrapper!(
+ recipe_by_name(name: &str) -> Recipe
+ as recipe_by_name_wrapped
+);
+mk_wrapper!(
+ recipe_by_id(id: RecipeId) -> Recipe
+ as recipe_by_id_wrapped
+);
-mk_wrapper!(products_registered() -> Vec<Product> as products_registered_wrapped);
-mk_wrapper!(products_in_storage() -> Vec<Product> as products_in_storage_wrapped);
+mk_wrapper!(
+ @external_config
+ register_recipe_parent(&config, recipe_parent_stub: RecipeParentStub) -> RecipeParentId
+ as register_recipe_parent_external_wrapped
+);
+mk_wrapper!(
+ recipe_parents_toplevel() -> Vec<RecipeParent>
+ as recipe_parents_toplevel_wrapped
+);
+mk_wrapper!(
+ @treat_404_as_None
+ recipe_parents_under(id: RecipeParentId) -> Option<Vec<RecipeParent>>
+ as recipe_parents_under_404_wrapped
+);
+mk_wrapper!(
+ recipe_parents() -> Vec<RecipeParent>
+ as recipe_parents_wrapped
+);
-mk_wrapper!(@external_config buy_barcode(&config, barcode_number: BarcodeId, times: u32) -> () as buy_barcode_external_wrapped);
-mk_wrapper!(@external_config register_product(&config, product_stub: ProductStub) -> ProductId as register_product_external_wrapped);
-mk_wrapper!(@external_config associate_barcode(&config, id: ProductId, barcode: Barcode) -> () as associate_barcode_external_wrapped);
+mk_wrapper!(
+ @external_config
+ buy_barcode(&config, barcode_number: BarcodeId, times: u32) -> ()
+ as buy_barcode_external_wrapped
+);
+mk_wrapper!(
+ @external_config
+ register_product(&config, product_stub: ProductStub) -> ProductId
+ as register_product_external_wrapped
+);
+mk_wrapper!(
+ @external_config
+ associate_barcode(&config, id: ProductId, barcode: Barcode) -> ()
+ as associate_barcode_external_wrapped
+);