1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
use crate::{
config::Configuration,
http::client::HttpClient,
models::{
errors::ApiError, CreateCustomerGroupRequest, CreateCustomerGroupResponse,
DeleteCustomerGroupResponse, ListCustomerGroupsParameters, ListCustomerGroupsResponse,
RetrieveCustomerGroupResponse, UpdateCustomerGroupRequest, UpdateCustomerGroupResponse,
},
};
const DEFAULT_URI: &str = "/customers/groups";
pub struct CustomerGroupsApi {
config: Configuration,
client: HttpClient,
}
impl CustomerGroupsApi {
pub fn new(config: Configuration, client: HttpClient) -> Self {
Self { config, client }
}
pub async fn list_customer_groups(
&self,
params: &ListCustomerGroupsParameters,
) -> Result<ListCustomerGroupsResponse, ApiError> {
let url = format!("{}{}", &self.url(), params.to_query_string());
let response = self.client.get(&url).await?;
response.deserialize().await
}
pub async fn create_customer_group(
&self,
body: &CreateCustomerGroupRequest,
) -> Result<CreateCustomerGroupResponse, ApiError> {
let response = self.client.post(&self.url(), body).await?;
response.deserialize().await
}
pub async fn delete_customer_group(
&self,
group_id: &str,
) -> Result<DeleteCustomerGroupResponse, ApiError> {
let url = format!("{}/{}", &self.url(), group_id);
let response = self.client.delete(&url).await?;
response.deserialize().await
}
pub async fn retrieve_customer_group(
&self,
group_id: &str,
) -> Result<RetrieveCustomerGroupResponse, ApiError> {
let url = format!("{}/{}", &self.url(), group_id);
let response = self.client.get(&url).await?;
response.deserialize().await
}
pub async fn update_customer_group(
&self,
group_id: &str,
body: &UpdateCustomerGroupRequest,
) -> Result<UpdateCustomerGroupResponse, ApiError> {
let url = format!("{}/{}", &self.url(), group_id);
let response = self.client.put(&url, body).await?;
response.deserialize().await
}
fn url(&self) -> String {
format!("{}{}", &self.config.get_base_url(), DEFAULT_URI)
}
}