tmf_client/tmf/
tmf622.rs

1//! TMF622 Product Order
2#[cfg(not(feature = "blocking"))]
3use crate::AsyncOperations;
4#[cfg(feature = "blocking")]
5use crate::BlockingOperations;
6use crate::{Config, HasNew};
7use tmflib::tmf622::product_order_v4::ProductOrder;
8
9use super::{create_tmf, delete_tmf, get_tmf, list_tmf, update_tmf};
10
11/// TMF622 Product Order Object
12pub struct TMF622ProductOrder {
13    /// End-point for TMF622
14    config: Config,
15}
16
17#[cfg(feature = "blocking")]
18impl BlockingOperations for TMF622ProductOrder {
19    type TMF = ProductOrder;
20
21    fn create(&self, item: Self::TMF) -> Result<Self::TMF, crate::common::tmf_error::TMFError> {
22        create_tmf(&self.config, item)
23    }
24
25    fn delete(
26        &self,
27        id: impl Into<String>,
28    ) -> Result<Self::TMF, crate::common::tmf_error::TMFError> {
29        delete_tmf(&self.config, id.into())
30    }
31
32    fn get(
33        &self,
34        id: impl Into<String>,
35    ) -> Result<Vec<Self::TMF>, crate::common::tmf_error::TMFError> {
36        get_tmf(&self.config, id.into())
37    }
38
39    fn list(
40        &self,
41        filter: Option<crate::QueryOptions>,
42    ) -> Result<Vec<Self::TMF>, crate::common::tmf_error::TMFError> {
43        list_tmf(&self.config, filter)
44    }
45
46    fn update(
47        &self,
48        id: impl Into<String>,
49        patch: Self::TMF,
50    ) -> Result<Self::TMF, crate::common::tmf_error::TMFError> {
51        update_tmf(&self.config, id.into(), patch)
52    }
53}
54
55#[cfg(not(feature = "blocking"))]
56impl AsyncOperations for TMF622ProductOrder {
57    type TMF = ProductOrder;
58
59    async fn create(
60        &self,
61        item: Self::TMF,
62    ) -> Result<Self::TMF, crate::common::tmf_error::TMFError> {
63        create_tmf(&self.config, item).await
64    }
65
66    async fn delete(
67        &self,
68        id: impl Into<String>,
69    ) -> Result<Self::TMF, crate::common::tmf_error::TMFError> {
70        delete_tmf(&self.config, id.into()).await
71    }
72
73    async fn get(
74        &self,
75        id: impl Into<String>,
76    ) -> Result<Vec<Self::TMF>, crate::common::tmf_error::TMFError> {
77        get_tmf(&self.config, id.into()).await
78    }
79
80    async fn list(
81        &self,
82        filter: Option<crate::QueryOptions>,
83    ) -> Result<Vec<Self::TMF>, crate::common::tmf_error::TMFError> {
84        list_tmf(&self.config, filter).await
85    }
86
87    async fn update(
88        &self,
89        id: impl Into<String>,
90        patch: Self::TMF,
91    ) -> Result<Self::TMF, crate::common::tmf_error::TMFError> {
92        update_tmf(&self.config, id.into(), patch).await
93    }
94}
95
96impl TMF622ProductOrder {
97    /// Create a new instance of Product Order API Object
98    pub fn new(config: Config) -> TMF622ProductOrder {
99        TMF622ProductOrder { config }
100    }
101}
102
103/// Product Ordering API
104#[derive(Clone, Debug)]
105pub struct TMF622 {
106    config: Config,
107}
108
109impl HasNew<TMF622> for TMF622 {
110    fn new(config: Config) -> TMF622 {
111        TMF622 { config }
112    }
113}
114
115impl TMF622 {
116    /// Access the order module of TMF622.
117    pub fn order(&self) -> TMF622ProductOrder {
118        TMF622ProductOrder::new(self.config.clone())
119    }
120}