1use tmflib::tmf632::organization_v4::Organization;
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#[cfg(feature = "v4")]
14use tmflib::tmf632::individual_v4::Individual;
15#[cfg(feature = "v5")]
16use tmflib::tmf632::individual_v5::Individual;
17
18pub struct TMF632Individual {
20 config: Config,
22}
23
24pub struct TMF632Organization {
26 config: Config,
27}
28
29impl TMF632Individual {
30 pub fn new(config: Config) -> TMF632Individual {
32 TMF632Individual { config }
33 }
34}
35
36#[cfg(feature = "blocking")]
37impl BlockingOperations for TMF632Individual {
38 type TMF = Individual;
39
40 fn create(&self, item: Self::TMF) -> Result<Self::TMF, TMFError> {
41 create_tmf(&self.config, item)
42 }
43 fn delete(&self, id: impl Into<String>) -> Result<Self::TMF, TMFError> {
44 delete_tmf(&self.config, id.into())
45 }
46 fn get(&self, id: impl Into<String>) -> Result<Vec<Self::TMF>, TMFError> {
47 get_tmf(&self.config, id.into())
48 }
49 fn list(&self, filter: Option<crate::QueryOptions>) -> Result<Vec<Self::TMF>, TMFError> {
50 list_tmf(&self.config, filter)
51 }
52 fn update(&self, id: impl Into<String>, patch: Self::TMF) -> Result<Self::TMF, TMFError> {
53 update_tmf(&self.config, id.into(), patch)
54 }
55}
56
57#[cfg(not(feature = "blocking"))]
58impl AsyncOperations for TMF632Individual {
59 type TMF = Individual;
60
61 async fn create(&self, item: Self::TMF) -> Result<Self::TMF, TMFError> {
62 create_tmf(&self.config, item).await
63 }
64 async fn delete(&self, id: impl Into<String>) -> Result<Self::TMF, TMFError> {
65 delete_tmf(&self.config, id.into()).await
66 }
67 async fn get(&self, id: impl Into<String>) -> Result<Vec<Self::TMF>, TMFError> {
68 get_tmf(&self.config, id.into()).await
69 }
70 async fn list(&self, filter: Option<crate::QueryOptions>) -> Result<Vec<Self::TMF>, TMFError> {
71 list_tmf(&self.config, filter).await
72 }
73 async fn update(&self, id: impl Into<String>, patch: Self::TMF) -> Result<Self::TMF, TMFError> {
74 update_tmf(&self.config, id.into(), patch).await
75 }
76}
77
78impl TMF632Organization {
79 pub fn new(config: Config) -> TMF632Organization {
81 TMF632Organization { config }
82 }
83}
84
85#[cfg(feature = "blocking")]
86impl BlockingOperations for TMF632Organization {
87 type TMF = Organization;
88
89 fn create(&self, item: Self::TMF) -> Result<Self::TMF, TMFError> {
90 create_tmf(&self.config, item)
91 }
92 fn delete(&self, id: impl Into<String>) -> Result<Self::TMF, TMFError> {
93 delete_tmf(&self.config, id.into())
94 }
95 fn get(&self, id: impl Into<String>) -> Result<Vec<Self::TMF>, TMFError> {
96 get_tmf(&self.config, id.into())
97 }
98 fn list(&self, filter: Option<crate::QueryOptions>) -> Result<Vec<Self::TMF>, TMFError> {
99 list_tmf(&self.config, filter)
100 }
101 fn update(&self, id: impl Into<String>, patch: Self::TMF) -> Result<Self::TMF, TMFError> {
102 update_tmf(&self.config, id.into(), patch)
103 }
104}
105
106#[cfg(not(feature = "blocking"))]
107impl AsyncOperations for TMF632Organization {
108 type TMF = Organization;
109
110 async fn create(&self, item: Self::TMF) -> Result<Self::TMF, TMFError> {
111 create_tmf(&self.config, item).await
112 }
113 async fn delete(&self, id: impl Into<String>) -> Result<Self::TMF, TMFError> {
114 delete_tmf(&self.config, id.into()).await
115 }
116 async fn get(&self, id: impl Into<String>) -> Result<Vec<Self::TMF>, TMFError> {
117 get_tmf(&self.config, id.into()).await
118 }
119 async fn list(&self, filter: Option<crate::QueryOptions>) -> Result<Vec<Self::TMF>, TMFError> {
120 list_tmf(&self.config, filter).await
121 }
122 async fn update(&self, id: impl Into<String>, patch: Self::TMF) -> Result<Self::TMF, TMFError> {
123 update_tmf(&self.config, id.into(), patch).await
124 }
125}
126
127#[derive(Clone, Debug)]
129pub struct TMF632 {
130 config: Config,
131}
132
133impl HasNew<TMF632> for TMF632 {
134 fn new(config: Config) -> TMF632 {
135 TMF632 { config }
136 }
137}
138
139impl TMF632 {
140 pub fn individual(&self) -> TMF632Individual {
142 TMF632Individual::new(self.config.clone())
143 }
144
145 pub fn organization(&self) -> TMF632Organization {
147 TMF632Organization::new(self.config.clone())
148 }
149}