1use stripe_client_core::{
2 RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5#[derive(Clone, Eq, PartialEq)]
6#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
7#[derive(serde::Serialize)]
8struct ListTransferBuilder {
9 #[serde(skip_serializing_if = "Option::is_none")]
10 created: Option<stripe_types::RangeQueryTs>,
11 #[serde(skip_serializing_if = "Option::is_none")]
12 destination: Option<String>,
13 #[serde(skip_serializing_if = "Option::is_none")]
14 ending_before: Option<String>,
15 #[serde(skip_serializing_if = "Option::is_none")]
16 expand: Option<Vec<String>>,
17 #[serde(skip_serializing_if = "Option::is_none")]
18 limit: Option<i64>,
19 #[serde(skip_serializing_if = "Option::is_none")]
20 starting_after: Option<String>,
21 #[serde(skip_serializing_if = "Option::is_none")]
22 transfer_group: Option<String>,
23}
24#[cfg(feature = "redact-generated-debug")]
25impl std::fmt::Debug for ListTransferBuilder {
26 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
27 f.debug_struct("ListTransferBuilder").finish_non_exhaustive()
28 }
29}
30impl ListTransferBuilder {
31 fn new() -> Self {
32 Self {
33 created: None,
34 destination: None,
35 ending_before: None,
36 expand: None,
37 limit: None,
38 starting_after: None,
39 transfer_group: None,
40 }
41 }
42}
43#[derive(Clone)]
46#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
47#[derive(serde::Serialize)]
48pub struct ListTransfer {
49 inner: ListTransferBuilder,
50}
51#[cfg(feature = "redact-generated-debug")]
52impl std::fmt::Debug for ListTransfer {
53 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
54 f.debug_struct("ListTransfer").finish_non_exhaustive()
55 }
56}
57impl ListTransfer {
58 pub fn new() -> Self {
60 Self { inner: ListTransferBuilder::new() }
61 }
62 pub fn created(mut self, created: impl Into<stripe_types::RangeQueryTs>) -> Self {
64 self.inner.created = Some(created.into());
65 self
66 }
67 pub fn destination(mut self, destination: impl Into<String>) -> Self {
69 self.inner.destination = Some(destination.into());
70 self
71 }
72 pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
76 self.inner.ending_before = Some(ending_before.into());
77 self
78 }
79 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
81 self.inner.expand = Some(expand.into());
82 self
83 }
84 pub fn limit(mut self, limit: impl Into<i64>) -> Self {
87 self.inner.limit = Some(limit.into());
88 self
89 }
90 pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
94 self.inner.starting_after = Some(starting_after.into());
95 self
96 }
97 pub fn transfer_group(mut self, transfer_group: impl Into<String>) -> Self {
99 self.inner.transfer_group = Some(transfer_group.into());
100 self
101 }
102}
103impl Default for ListTransfer {
104 fn default() -> Self {
105 Self::new()
106 }
107}
108impl ListTransfer {
109 pub async fn send<C: StripeClient>(
111 &self,
112 client: &C,
113 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
114 self.customize().send(client).await
115 }
116
117 pub fn send_blocking<C: StripeBlockingClient>(
119 &self,
120 client: &C,
121 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
122 self.customize().send_blocking(client)
123 }
124
125 pub fn paginate(
126 &self,
127 ) -> stripe_client_core::ListPaginator<stripe_types::List<stripe_shared::Transfer>> {
128 stripe_client_core::ListPaginator::new_list("/transfers", &self.inner)
129 }
130}
131
132impl StripeRequest for ListTransfer {
133 type Output = stripe_types::List<stripe_shared::Transfer>;
134
135 fn build(&self) -> RequestBuilder {
136 RequestBuilder::new(StripeMethod::Get, "/transfers").query(&self.inner)
137 }
138}
139#[derive(Clone, Eq, PartialEq)]
140#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
141#[derive(serde::Serialize)]
142struct RetrieveTransferBuilder {
143 #[serde(skip_serializing_if = "Option::is_none")]
144 expand: Option<Vec<String>>,
145}
146#[cfg(feature = "redact-generated-debug")]
147impl std::fmt::Debug for RetrieveTransferBuilder {
148 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
149 f.debug_struct("RetrieveTransferBuilder").finish_non_exhaustive()
150 }
151}
152impl RetrieveTransferBuilder {
153 fn new() -> Self {
154 Self { expand: None }
155 }
156}
157#[derive(Clone)]
160#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
161#[derive(serde::Serialize)]
162pub struct RetrieveTransfer {
163 inner: RetrieveTransferBuilder,
164 transfer: stripe_shared::TransferId,
165}
166#[cfg(feature = "redact-generated-debug")]
167impl std::fmt::Debug for RetrieveTransfer {
168 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
169 f.debug_struct("RetrieveTransfer").finish_non_exhaustive()
170 }
171}
172impl RetrieveTransfer {
173 pub fn new(transfer: impl Into<stripe_shared::TransferId>) -> Self {
175 Self { transfer: transfer.into(), inner: RetrieveTransferBuilder::new() }
176 }
177 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
179 self.inner.expand = Some(expand.into());
180 self
181 }
182}
183impl RetrieveTransfer {
184 pub async fn send<C: StripeClient>(
186 &self,
187 client: &C,
188 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
189 self.customize().send(client).await
190 }
191
192 pub fn send_blocking<C: StripeBlockingClient>(
194 &self,
195 client: &C,
196 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
197 self.customize().send_blocking(client)
198 }
199}
200
201impl StripeRequest for RetrieveTransfer {
202 type Output = stripe_shared::Transfer;
203
204 fn build(&self) -> RequestBuilder {
205 let transfer = &self.transfer;
206 RequestBuilder::new(StripeMethod::Get, format!("/transfers/{transfer}")).query(&self.inner)
207 }
208}
209#[derive(Clone)]
210#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
211#[derive(serde::Serialize)]
212struct CreateTransferBuilder {
213 #[serde(skip_serializing_if = "Option::is_none")]
214 amount: Option<i64>,
215 currency: stripe_types::Currency,
216 #[serde(skip_serializing_if = "Option::is_none")]
217 description: Option<String>,
218 destination: String,
219 #[serde(skip_serializing_if = "Option::is_none")]
220 expand: Option<Vec<String>>,
221 #[serde(skip_serializing_if = "Option::is_none")]
222 metadata: Option<std::collections::HashMap<String, String>>,
223 #[serde(skip_serializing_if = "Option::is_none")]
224 source_transaction: Option<String>,
225 #[serde(skip_serializing_if = "Option::is_none")]
226 source_type: Option<CreateTransferSourceType>,
227 #[serde(skip_serializing_if = "Option::is_none")]
228 transfer_group: Option<String>,
229}
230#[cfg(feature = "redact-generated-debug")]
231impl std::fmt::Debug for CreateTransferBuilder {
232 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
233 f.debug_struct("CreateTransferBuilder").finish_non_exhaustive()
234 }
235}
236impl CreateTransferBuilder {
237 fn new(currency: impl Into<stripe_types::Currency>, destination: impl Into<String>) -> Self {
238 Self {
239 amount: None,
240 currency: currency.into(),
241 description: None,
242 destination: destination.into(),
243 expand: None,
244 metadata: None,
245 source_transaction: None,
246 source_type: None,
247 transfer_group: None,
248 }
249 }
250}
251#[derive(Clone, Eq, PartialEq)]
255#[non_exhaustive]
256pub enum CreateTransferSourceType {
257 BankAccount,
258 Card,
259 Fpx,
260 Unknown(String),
262}
263impl CreateTransferSourceType {
264 pub fn as_str(&self) -> &str {
265 use CreateTransferSourceType::*;
266 match self {
267 BankAccount => "bank_account",
268 Card => "card",
269 Fpx => "fpx",
270 Unknown(v) => v,
271 }
272 }
273}
274
275impl std::str::FromStr for CreateTransferSourceType {
276 type Err = std::convert::Infallible;
277 fn from_str(s: &str) -> Result<Self, Self::Err> {
278 use CreateTransferSourceType::*;
279 match s {
280 "bank_account" => Ok(BankAccount),
281 "card" => Ok(Card),
282 "fpx" => Ok(Fpx),
283 v => {
284 tracing::warn!("Unknown value '{}' for enum '{}'", v, "CreateTransferSourceType");
285 Ok(Unknown(v.to_owned()))
286 }
287 }
288 }
289}
290impl std::fmt::Display for CreateTransferSourceType {
291 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
292 f.write_str(self.as_str())
293 }
294}
295
296#[cfg(not(feature = "redact-generated-debug"))]
297impl std::fmt::Debug for CreateTransferSourceType {
298 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
299 f.write_str(self.as_str())
300 }
301}
302#[cfg(feature = "redact-generated-debug")]
303impl std::fmt::Debug for CreateTransferSourceType {
304 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
305 f.debug_struct(stringify!(CreateTransferSourceType)).finish_non_exhaustive()
306 }
307}
308impl serde::Serialize for CreateTransferSourceType {
309 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
310 where
311 S: serde::Serializer,
312 {
313 serializer.serialize_str(self.as_str())
314 }
315}
316#[cfg(feature = "deserialize")]
317impl<'de> serde::Deserialize<'de> for CreateTransferSourceType {
318 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
319 use std::str::FromStr;
320 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
321 Ok(Self::from_str(&s).expect("infallible"))
322 }
323}
324#[derive(Clone)]
327#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
328#[derive(serde::Serialize)]
329pub struct CreateTransfer {
330 inner: CreateTransferBuilder,
331}
332#[cfg(feature = "redact-generated-debug")]
333impl std::fmt::Debug for CreateTransfer {
334 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
335 f.debug_struct("CreateTransfer").finish_non_exhaustive()
336 }
337}
338impl CreateTransfer {
339 pub fn new(
341 currency: impl Into<stripe_types::Currency>,
342 destination: impl Into<String>,
343 ) -> Self {
344 Self { inner: CreateTransferBuilder::new(currency.into(), destination.into()) }
345 }
346 pub fn amount(mut self, amount: impl Into<i64>) -> Self {
348 self.inner.amount = Some(amount.into());
349 self
350 }
351 pub fn description(mut self, description: impl Into<String>) -> Self {
353 self.inner.description = Some(description.into());
354 self
355 }
356 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
358 self.inner.expand = Some(expand.into());
359 self
360 }
361 pub fn metadata(
366 mut self,
367 metadata: impl Into<std::collections::HashMap<String, String>>,
368 ) -> Self {
369 self.inner.metadata = Some(metadata.into());
370 self
371 }
372 pub fn source_transaction(mut self, source_transaction: impl Into<String>) -> Self {
376 self.inner.source_transaction = Some(source_transaction.into());
377 self
378 }
379 pub fn source_type(mut self, source_type: impl Into<CreateTransferSourceType>) -> Self {
383 self.inner.source_type = Some(source_type.into());
384 self
385 }
386 pub fn transfer_group(mut self, transfer_group: impl Into<String>) -> Self {
389 self.inner.transfer_group = Some(transfer_group.into());
390 self
391 }
392}
393impl CreateTransfer {
394 pub async fn send<C: StripeClient>(
396 &self,
397 client: &C,
398 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
399 self.customize().send(client).await
400 }
401
402 pub fn send_blocking<C: StripeBlockingClient>(
404 &self,
405 client: &C,
406 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
407 self.customize().send_blocking(client)
408 }
409}
410
411impl StripeRequest for CreateTransfer {
412 type Output = stripe_shared::Transfer;
413
414 fn build(&self) -> RequestBuilder {
415 RequestBuilder::new(StripeMethod::Post, "/transfers").form(&self.inner)
416 }
417}
418#[derive(Clone)]
419#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
420#[derive(serde::Serialize)]
421struct UpdateTransferBuilder {
422 #[serde(skip_serializing_if = "Option::is_none")]
423 description: Option<String>,
424 #[serde(skip_serializing_if = "Option::is_none")]
425 expand: Option<Vec<String>>,
426 #[serde(skip_serializing_if = "Option::is_none")]
427 metadata: Option<std::collections::HashMap<String, String>>,
428}
429#[cfg(feature = "redact-generated-debug")]
430impl std::fmt::Debug for UpdateTransferBuilder {
431 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
432 f.debug_struct("UpdateTransferBuilder").finish_non_exhaustive()
433 }
434}
435impl UpdateTransferBuilder {
436 fn new() -> Self {
437 Self { description: None, expand: None, metadata: None }
438 }
439}
440#[derive(Clone)]
445#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
446#[derive(serde::Serialize)]
447pub struct UpdateTransfer {
448 inner: UpdateTransferBuilder,
449 transfer: stripe_shared::TransferId,
450}
451#[cfg(feature = "redact-generated-debug")]
452impl std::fmt::Debug for UpdateTransfer {
453 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
454 f.debug_struct("UpdateTransfer").finish_non_exhaustive()
455 }
456}
457impl UpdateTransfer {
458 pub fn new(transfer: impl Into<stripe_shared::TransferId>) -> Self {
460 Self { transfer: transfer.into(), inner: UpdateTransferBuilder::new() }
461 }
462 pub fn description(mut self, description: impl Into<String>) -> Self {
464 self.inner.description = Some(description.into());
465 self
466 }
467 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
469 self.inner.expand = Some(expand.into());
470 self
471 }
472 pub fn metadata(
477 mut self,
478 metadata: impl Into<std::collections::HashMap<String, String>>,
479 ) -> Self {
480 self.inner.metadata = Some(metadata.into());
481 self
482 }
483}
484impl UpdateTransfer {
485 pub async fn send<C: StripeClient>(
487 &self,
488 client: &C,
489 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
490 self.customize().send(client).await
491 }
492
493 pub fn send_blocking<C: StripeBlockingClient>(
495 &self,
496 client: &C,
497 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
498 self.customize().send_blocking(client)
499 }
500}
501
502impl StripeRequest for UpdateTransfer {
503 type Output = stripe_shared::Transfer;
504
505 fn build(&self) -> RequestBuilder {
506 let transfer = &self.transfer;
507 RequestBuilder::new(StripeMethod::Post, format!("/transfers/{transfer}")).form(&self.inner)
508 }
509}