1use tmflib::tmf637::v4::product::Product;
4
5use super::{create_tmf, delete_tmf, get_tmf, list_tmf, update_tmf};
6use crate::common::tmf_error::TMFError;
7#[cfg(not(feature = "blocking"))]
8use crate::AsyncOperations;
9#[cfg(feature = "blocking")]
10use crate::BlockingOperations;
11use crate::{Config, HasNew};
12
13pub struct TMF637ProductInventoryManagement {
36 config: Config,
37}
38
39impl TMF637ProductInventoryManagement {
40 pub fn new(config: Config) -> TMF637ProductInventoryManagement {
42 TMF637ProductInventoryManagement { config }
43 }
44}
45
46#[cfg(feature = "blocking")]
47impl BlockingOperations for TMF637ProductInventoryManagement {
48 type TMF = Product;
49
50 fn create(&self, item: Self::TMF) -> Result<Self::TMF, TMFError> {
51 create_tmf(&self.config, item)
52 }
53 fn delete(&self, id: impl Into<String>) -> Result<Self::TMF, TMFError> {
54 delete_tmf(&self.config, id.into())
55 }
56 fn get(&self, id: impl Into<String>) -> Result<Vec<Self::TMF>, TMFError> {
57 get_tmf(&self.config, id.into())
58 }
59 fn list(&self, filter: Option<crate::QueryOptions>) -> Result<Vec<Self::TMF>, TMFError> {
60 list_tmf(&self.config, filter)
61 }
62 fn update(&self, id: impl Into<String>, patch: Self::TMF) -> Result<Self::TMF, TMFError> {
63 update_tmf(&self.config, id.into(), patch)
64 }
65}
66
67#[cfg(not(feature = "blocking"))]
68impl AsyncOperations for TMF637ProductInventoryManagement {
69 type TMF = Product;
70
71 async fn create(&self, item: Self::TMF) -> Result<Self::TMF, TMFError> {
72 create_tmf(&self.config, item).await
73 }
74 async fn delete(&self, id: impl Into<String>) -> Result<Self::TMF, TMFError> {
75 delete_tmf(&self.config, id.into()).await
76 }
77 async fn get(&self, id: impl Into<String>) -> Result<Vec<Self::TMF>, TMFError> {
78 get_tmf(&self.config, id.into()).await
79 }
80 async fn list(&self, filter: Option<crate::QueryOptions>) -> Result<Vec<Self::TMF>, TMFError> {
81 list_tmf(&self.config, filter).await
82 }
83 async fn update(&self, id: impl Into<String>, patch: Self::TMF) -> Result<Self::TMF, TMFError> {
84 update_tmf(&self.config, id.into(), patch).await
85 }
86}
87
88#[derive(Clone, Default, Debug)]
90pub struct TMF637 {
91 config: Config,
92}
93
94impl HasNew<TMF637> for TMF637 {
95 fn new(config: Config) -> TMF637 {
96 TMF637 { config }
97 }
98}
99
100impl TMF637 {
101 pub fn product(&mut self) -> TMF637ProductInventoryManagement {
103 super::tmf637::TMF637ProductInventoryManagement::new(self.config.clone())
104 }
105}