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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
use crate::api::*;
use crate::{ApiError, ClientConfig, HttpClient, QueryBuilder, RequestOptions};
use reqwest::Method;
pub struct PaymentMethodDomainClient {
pub http_client: HttpClient,
}
impl PaymentMethodDomainClient {
pub fn new(config: ClientConfig) -> Result<Self, ApiError> {
Ok(Self {
http_client: HttpClient::new(config.clone())?,
})
}
/// Add a payment method domain to an organization or paypoint.
///
/// # Arguments
///
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn add_payment_method_domain(
&self,
request: &AddPaymentMethodDomainRequest,
options: Option<RequestOptions>,
) -> Result<AddPaymentMethodDomainApiResponse, ApiError> {
self.http_client
.execute_request(
Method::POST,
"PaymentMethodDomain",
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
/// Cascades a payment method domain to all child entities. All paypoints and suborganization under this parent will inherit this domain and its settings.
///
/// # Arguments
///
/// * `domain_id` - The payment method domain's ID in Payabli.
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn cascade_payment_method_domain(
&self,
domain_id: &str,
options: Option<RequestOptions>,
) -> Result<PaymentMethodDomainGeneralResponse, ApiError> {
self.http_client
.execute_request(
Method::POST,
&format!("PaymentMethodDomain/{}/cascade", domain_id),
None,
None,
options,
)
.await
}
/// Delete a payment method domain. You can't delete an inherited domain, you must delete a domain at the organization level.
///
/// # Arguments
///
/// * `domain_id` - The payment method domain's ID in Payabli.
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn delete_payment_method_domain(
&self,
domain_id: &str,
options: Option<RequestOptions>,
) -> Result<DeletePaymentMethodDomainResponse, ApiError> {
self.http_client
.execute_request(
Method::DELETE,
&format!("PaymentMethodDomain/{}", domain_id),
None,
None,
options,
)
.await
}
/// Get the details for a payment method domain.
///
/// # Arguments
///
/// * `domain_id` - The payment method domain's ID in Payabli.
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn get_payment_method_domain(
&self,
domain_id: &str,
options: Option<RequestOptions>,
) -> Result<PaymentMethodDomainApiResponse, ApiError> {
self.http_client
.execute_request(
Method::GET,
&format!("PaymentMethodDomain/{}", domain_id),
None,
None,
options,
)
.await
}
/// Get a list of payment method domains that belong to a PSP, organization, or paypoint.
///
/// # Arguments
///
/// * `entity_id` - Identifier for the organization or paypoint.
/// - For organization, provide the organization ID - For paypoint, provide the paypoint ID
/// * `entity_type` - The type of entity. Valid values:
/// - organization
/// - paypoint
/// - psp
/// * `from_record` - Number of records to skip. Defaults to `0`.
/// * `limit_record` - Max number of records for query response. Defaults to `20`.
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn list_payment_method_domains(
&self,
request: &ListPaymentMethodDomainsQueryRequest,
options: Option<RequestOptions>,
) -> Result<ListPaymentMethodDomainsResponse, ApiError> {
self.http_client
.execute_request(
Method::GET,
"PaymentMethodDomain/list",
None,
QueryBuilder::new()
.int("entityId", request.entity_id.clone())
.string("entityType", request.entity_type.clone())
.int("fromRecord", request.from_record.clone())
.int("limitRecord", request.limit_record.clone())
.build(),
options,
)
.await
}
/// Update a payment method domain's configuration values.
///
/// # Arguments
///
/// * `domain_id` - The payment method domain's ID in Payabli.
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn update_payment_method_domain(
&self,
domain_id: &str,
request: &UpdatePaymentMethodDomainRequest,
options: Option<RequestOptions>,
) -> Result<PaymentMethodDomainGeneralResponse, ApiError> {
self.http_client
.execute_request(
Method::PATCH,
&format!("PaymentMethodDomain/{}", domain_id),
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
/// Verify a new payment method domain. If verification is successful, Apple Pay is automatically activated for the domain.
///
/// # Arguments
///
/// * `domain_id` - The payment method domain's ID in Payabli.
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn verify_payment_method_domain(
&self,
domain_id: &str,
options: Option<RequestOptions>,
) -> Result<PaymentMethodDomainGeneralResponse, ApiError> {
self.http_client
.execute_request(
Method::POST,
&format!("PaymentMethodDomain/{}/verify", domain_id),
None,
None,
options,
)
.await
}
}