1use tmflib::tmf663::shopping_cart::ShoppingCart;
9
10use super::{create_tmf, delete_tmf, get_tmf, list_tmf, update_tmf};
11use crate::common::tmf_error::TMFError;
12#[cfg(not(feature = "blocking"))]
13use crate::AsyncOperations;
14#[cfg(feature = "blocking")]
15use crate::BlockingOperations;
16use crate::{Config, HasNew};
17
18#[derive(Clone, Default, Debug)]
20pub struct TMF663ShoppingCart {
21 config: Config,
22}
23
24#[derive(Clone, Default, Debug)]
26pub struct TMF663 {
27 config: Config,
28}
29
30impl HasNew<TMF663> for TMF663 {
31 fn new(config: Config) -> TMF663 {
32 TMF663 { config }
33 }
34}
35
36impl TMF663 {
37 pub fn shopping_cart(&self) -> TMF663ShoppingCart {
47 TMF663ShoppingCart {
48 config: self.config.clone(),
49 }
50 }
51}
52#[cfg(feature = "blocking")]
53impl BlockingOperations for TMF663ShoppingCart {
54 type TMF = ShoppingCart;
55
56 fn create(&self, item: Self::TMF) -> Result<Self::TMF, TMFError> {
57 create_tmf(&self.config, item)
58 }
59 fn delete(&self, id: impl Into<String>) -> Result<Self::TMF, TMFError> {
60 delete_tmf(&self.config, id)
61 }
62 fn get(&self, id: impl Into<String>) -> Result<Vec<Self::TMF>, TMFError> {
63 get_tmf(&self.config, id.into())
64 }
65 fn list(&self, filter: Option<crate::QueryOptions>) -> Result<Vec<Self::TMF>, TMFError> {
66 list_tmf(&self.config, filter)
67 }
68 fn update(&self, id: impl Into<String>, patch: Self::TMF) -> Result<Self::TMF, TMFError> {
69 update_tmf(&self.config, id, patch)
70 }
71}
72
73#[cfg(not(feature = "blocking"))]
74impl AsyncOperations for TMF663ShoppingCart {
75 type TMF = ShoppingCart;
76
77 async fn create(&self, item: Self::TMF) -> Result<Self::TMF, TMFError> {
78 create_tmf(&self.config, item).await
79 }
80 async fn delete(&self, id: impl Into<String>) -> Result<Self::TMF, TMFError> {
81 delete_tmf(&self.config, id).await
82 }
83 async fn get(&self, id: impl Into<String>) -> Result<Vec<Self::TMF>, TMFError> {
84 get_tmf(&self.config, id.into()).await
85 }
86 async fn list(&self, filter: Option<crate::QueryOptions>) -> Result<Vec<Self::TMF>, TMFError> {
87 list_tmf(&self.config, filter).await
88 }
89 async fn update(&self, id: impl Into<String>, patch: Self::TMF) -> Result<Self::TMF, TMFError> {
90 update_tmf(&self.config, id, patch).await
91 }
92}