about summary refs log tree commit diff stats
path: root/crates/rocie-cli/src/handle
diff options
context:
space:
mode:
Diffstat (limited to 'crates/rocie-cli/src/handle')
-rw-r--r--crates/rocie-cli/src/handle/mod.rs31
1 files changed, 12 insertions, 19 deletions
diff --git a/crates/rocie-cli/src/handle/mod.rs b/crates/rocie-cli/src/handle/mod.rs
index 929c0ff..4e63696 100644
--- a/crates/rocie-cli/src/handle/mod.rs
+++ b/crates/rocie-cli/src/handle/mod.rs
@@ -4,7 +4,7 @@ use anyhow::{Context, Result};
 use rocie_client::{
     apis::{
         api_get_inventory_api::amount_by_id,
-        api_get_product_api::{product_by_id, products},
+        api_get_product_api::{product_by_id, products_registered},
         api_get_unit_api::{unit_by_id, units},
         api_get_unit_property_api::{unit_properties, unit_property_by_id},
         api_set_barcode_api::{buy_barcode, consume_barcode},
@@ -14,11 +14,12 @@ use rocie_client::{
         configuration::Configuration,
     },
     models::{
-        Barcode, BarcodeId, ProductId, UnitAmount, UnitId, UnitPropertyId, UnitPropertyStub,
-        UnitStub,
+        Barcode, BarcodeId, ProductId, ProductParentId, UnitAmount, UnitId, UnitPropertyId,
+        UnitPropertyStub, UnitStub,
     },
 };
 
+#[expect(clippy::too_many_lines)]
 pub(crate) async fn product(config: &Configuration, command: ProductCommand) -> Result<()> {
     match command {
         ProductCommand::Register {
@@ -30,12 +31,12 @@ pub(crate) async fn product(config: &Configuration, command: ProductCommand) ->
             let new_id = register_product(
                 config,
                 rocie_client::models::ProductStub {
-                    description: Some(description), // TODO: Fix the duplicate option
+                    description,
                     name,
                     unit_property: UnitPropertyId {
                         value: unit_property,
                     },
-                    parent: Some(parent.map(|p| ProductId { value: p })),
+                    parent: parent.map(|p| ProductParentId { value: p }),
                 },
             )
             .await
@@ -92,7 +93,7 @@ pub(crate) async fn product(config: &Configuration, command: ProductCommand) ->
         }
 
         ProductCommand::List {} => {
-            let all = products(config)
+            let all = products_registered(config)
                 .await
                 .context("Failed to get all products")?;
 
@@ -113,10 +114,7 @@ pub(crate) async fn product(config: &Configuration, command: ProductCommand) ->
                     );
                 }
 
-                if let Some(description) = product
-                    .description
-                    .expect("Superflous Option wrapping in api")
-                {
+                if let Some(description) = product.description {
                     println!(" ({description})");
                 } else {
                     println!();
@@ -183,7 +181,7 @@ pub(crate) async fn unit(config: &Configuration, command: UnitCommand) -> Result
             let new_id = register_unit(
                 config,
                 UnitStub {
-                    description: Some(description),
+                    description,
                     full_name_plural,
                     full_name_singular,
                     short_name,
@@ -202,9 +200,7 @@ pub(crate) async fn unit(config: &Configuration, command: UnitCommand) -> Result
             for unit in all {
                 print!("{}: {}", unit.full_name_singular, unit.id);
 
-                if let Some(description) =
-                    unit.description.expect("Superflous Option wrapping in api")
-                {
+                if let Some(description) = unit.description {
                     println!(" ({description})");
                 } else {
                     println!();
@@ -234,7 +230,7 @@ pub(crate) async fn unit_property(
             let new_id = register_unit_property(
                 config,
                 UnitPropertyStub {
-                    description: Some(description),
+                    description,
                     name,
                 },
             )
@@ -250,10 +246,7 @@ pub(crate) async fn unit_property(
             for unit_prop in all {
                 print!("{}: {}", unit_prop.name, unit_prop.id);
 
-                if let Some(description) = unit_prop
-                    .description
-                    .expect("Superflous Option wrapping in api")
-                {
+                if let Some(description) = unit_prop.description {
                     println!(" ({description})");
                 } else {
                     println!();