tmf_client/tmf/
tmf637.rs

1//! TMF637 Product Inventory Management API
2
3use 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
13// /// TMF645 Service Qualification API
14// #[derive(Clone,Default,Debug)]
15// pub struct TMF645 {
16//     host : Uri,
17// }
18
19// impl HasNew<TMF645> for TMF645 {
20//     fn new(host : Uri) -> TMF645 {
21//         TMF645 {
22//             host
23//         }
24//     }
25// }
26
27// impl TMF645 {
28//     /// Access the Check Service Qualification API
29//     pub fn check_qualifcation(&mut self) -> TMF645CheckServiceQualification {
30//         TMF645CheckServiceQualification::new(self.config)
31//     }
32// }
33
34/// TMF637 Product Inventory Management API
35pub struct TMF637ProductInventoryManagement {
36    config: Config,
37}
38
39impl TMF637ProductInventoryManagement {
40    /// Create a new instance of the Product Inventory Management module of TMF637 API
41    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/// TMF637 Product Inventory Management API
89#[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    /// Access the Product Inventory Management API
102    pub fn product(&mut self) -> TMF637ProductInventoryManagement {
103        super::tmf637::TMF637ProductInventoryManagement::new(self.config.clone())
104    }
105}