tmf_client/tmf/
tmf663.rs

1//! TMF663 Shopping Cart API
2
3//!! This module provides access to the TMF663 Shopping Cart API, allowing
4//! for operations such as creating, retrieving, and managing shopping carts.
5//! It is designed to be used with the TMFClient, which provides a convenient
6//! interface for interacting with the API.
7
8use 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/// TMF663 Shopping Cart API Object
19#[derive(Clone, Default, Debug)]
20pub struct TMF663ShoppingCart {
21    config: Config,
22}
23
24/// Operations trait implementation for TMF663ShoppingCart
25#[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    /// Provide a ShoppingCart API object
38    /// This method returns an instance of TMF663ShoppingCart, which can be used
39    /// to perform operations related to shopping carts.
40    /// ```
41    /// # use tmf_client::TMFClient;
42    /// let shopping_cart = TMFClient::new("http://localhost",None)
43    ///     .tmf663()
44    ///     .shopping_cart();
45    /// ```
46    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}