tmf_client/tmf/
tmf629.rs

1//! TMF629 Module
2//! Manage objects with TMF629 Customer Management API.
3
4use tmflib::tmf629::customer::Customer;
5
6use super::{create_tmf, delete_tmf, get_tmf, list_tmf, update_tmf};
7use crate::common::tmf_error::TMFError;
8#[cfg(not(feature = "blocking"))]
9use crate::AsyncOperations;
10#[cfg(feature = "blocking")]
11use crate::BlockingOperations;
12use crate::{Config, HasNew};
13
14/// TMF629 Customer API
15pub struct TMF629Customer {
16    config: Config,
17}
18
19impl TMF629Customer {
20    /// Create a new instance of the Customer module of TMF629 API
21    pub fn new(config: Config) -> TMF629Customer {
22        TMF629Customer { config }
23    }
24}
25
26#[cfg(feature = "blocking")]
27impl BlockingOperations for TMF629Customer {
28    type TMF = Customer;
29
30    fn create(&self, item: Self::TMF) -> Result<Self::TMF, TMFError> {
31        create_tmf(&self.config, item)
32    }
33    fn delete(&self, id: impl Into<String>) -> Result<Self::TMF, TMFError> {
34        delete_tmf(&self.config, id.into())
35    }
36    fn get(&self, id: impl Into<String>) -> Result<Vec<Self::TMF>, TMFError> {
37        get_tmf(&self.config, id.into())
38    }
39    fn list(&self, filter: Option<crate::QueryOptions>) -> Result<Vec<Self::TMF>, TMFError> {
40        list_tmf(&self.config, filter)
41    }
42    fn update(&self, id: impl Into<String>, patch: Self::TMF) -> Result<Self::TMF, TMFError> {
43        update_tmf(&self.config, id.into(), patch)
44    }
45}
46
47#[cfg(not(feature = "blocking"))]
48impl AsyncOperations for TMF629Customer {
49    type TMF = Customer;
50
51    async fn create(&self, item: Self::TMF) -> Result<Self::TMF, TMFError> {
52        create_tmf(&self.config, item).await
53    }
54    async fn delete(&self, id: impl Into<String>) -> Result<Self::TMF, TMFError> {
55        delete_tmf(&self.config, id.into()).await
56    }
57    async fn get(&self, id: impl Into<String>) -> Result<Vec<Self::TMF>, TMFError> {
58        get_tmf(&self.config, id.into()).await
59    }
60    async fn list(&self, filter: Option<crate::QueryOptions>) -> Result<Vec<Self::TMF>, TMFError> {
61        list_tmf(&self.config, filter).await
62    }
63    async fn update(&self, id: impl Into<String>, patch: Self::TMF) -> Result<Self::TMF, TMFError> {
64        update_tmf(&self.config, id.into(), patch).await
65    }
66}
67
68/// TMF629 Customer Management API
69#[derive(Clone, Debug)]
70pub struct TMF629 {
71    config: Config,
72}
73
74impl HasNew<TMF629> for TMF629 {
75    fn new(config: Config) -> TMF629 {
76        TMF629 { config }
77    }
78}
79
80impl TMF629 {
81    /// Access the Customer API
82    pub fn customer(&mut self) -> TMF629Customer {
83        TMF629Customer::new(self.config.clone())
84    }
85}