1use stripe_client_core::{
2 RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5#[derive(Clone, Debug, serde::Serialize)]
6struct ListPayoutBuilder {
7 #[serde(skip_serializing_if = "Option::is_none")]
8 arrival_date: Option<stripe_types::RangeQueryTs>,
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 status: Option<String>,
23}
24impl ListPayoutBuilder {
25 fn new() -> Self {
26 Self {
27 arrival_date: None,
28 created: None,
29 destination: None,
30 ending_before: None,
31 expand: None,
32 limit: None,
33 starting_after: None,
34 status: None,
35 }
36 }
37}
38#[derive(Clone, Debug, serde::Serialize)]
41pub struct ListPayout {
42 inner: ListPayoutBuilder,
43}
44impl ListPayout {
45 pub fn new() -> Self {
47 Self { inner: ListPayoutBuilder::new() }
48 }
49 pub fn arrival_date(mut self, arrival_date: impl Into<stripe_types::RangeQueryTs>) -> Self {
51 self.inner.arrival_date = Some(arrival_date.into());
52 self
53 }
54 pub fn created(mut self, created: impl Into<stripe_types::RangeQueryTs>) -> Self {
56 self.inner.created = Some(created.into());
57 self
58 }
59 pub fn destination(mut self, destination: impl Into<String>) -> Self {
61 self.inner.destination = Some(destination.into());
62 self
63 }
64 pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
68 self.inner.ending_before = Some(ending_before.into());
69 self
70 }
71 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
73 self.inner.expand = Some(expand.into());
74 self
75 }
76 pub fn limit(mut self, limit: impl Into<i64>) -> Self {
79 self.inner.limit = Some(limit.into());
80 self
81 }
82 pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
86 self.inner.starting_after = Some(starting_after.into());
87 self
88 }
89 pub fn status(mut self, status: impl Into<String>) -> Self {
91 self.inner.status = Some(status.into());
92 self
93 }
94}
95impl Default for ListPayout {
96 fn default() -> Self {
97 Self::new()
98 }
99}
100impl ListPayout {
101 pub async fn send<C: StripeClient>(
103 &self,
104 client: &C,
105 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
106 self.customize().send(client).await
107 }
108
109 pub fn send_blocking<C: StripeBlockingClient>(
111 &self,
112 client: &C,
113 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
114 self.customize().send_blocking(client)
115 }
116
117 pub fn paginate(
118 &self,
119 ) -> stripe_client_core::ListPaginator<stripe_types::List<stripe_shared::Payout>> {
120 stripe_client_core::ListPaginator::new_list("/payouts", &self.inner)
121 }
122}
123
124impl StripeRequest for ListPayout {
125 type Output = stripe_types::List<stripe_shared::Payout>;
126
127 fn build(&self) -> RequestBuilder {
128 RequestBuilder::new(StripeMethod::Get, "/payouts").query(&self.inner)
129 }
130}
131#[derive(Clone, Debug, serde::Serialize)]
132struct RetrievePayoutBuilder {
133 #[serde(skip_serializing_if = "Option::is_none")]
134 expand: Option<Vec<String>>,
135}
136impl RetrievePayoutBuilder {
137 fn new() -> Self {
138 Self { expand: None }
139 }
140}
141#[derive(Clone, Debug, serde::Serialize)]
145pub struct RetrievePayout {
146 inner: RetrievePayoutBuilder,
147 payout: stripe_shared::PayoutId,
148}
149impl RetrievePayout {
150 pub fn new(payout: impl Into<stripe_shared::PayoutId>) -> Self {
152 Self { payout: payout.into(), inner: RetrievePayoutBuilder::new() }
153 }
154 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
156 self.inner.expand = Some(expand.into());
157 self
158 }
159}
160impl RetrievePayout {
161 pub async fn send<C: StripeClient>(
163 &self,
164 client: &C,
165 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
166 self.customize().send(client).await
167 }
168
169 pub fn send_blocking<C: StripeBlockingClient>(
171 &self,
172 client: &C,
173 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
174 self.customize().send_blocking(client)
175 }
176}
177
178impl StripeRequest for RetrievePayout {
179 type Output = stripe_shared::Payout;
180
181 fn build(&self) -> RequestBuilder {
182 let payout = &self.payout;
183 RequestBuilder::new(StripeMethod::Get, format!("/payouts/{payout}")).query(&self.inner)
184 }
185}
186#[derive(Clone, Debug, serde::Serialize)]
187struct CreatePayoutBuilder {
188 amount: i64,
189 currency: stripe_types::Currency,
190 #[serde(skip_serializing_if = "Option::is_none")]
191 description: Option<String>,
192 #[serde(skip_serializing_if = "Option::is_none")]
193 destination: Option<String>,
194 #[serde(skip_serializing_if = "Option::is_none")]
195 expand: Option<Vec<String>>,
196 #[serde(skip_serializing_if = "Option::is_none")]
197 metadata: Option<std::collections::HashMap<String, String>>,
198 #[serde(skip_serializing_if = "Option::is_none")]
199 method: Option<CreatePayoutMethod>,
200 #[serde(skip_serializing_if = "Option::is_none")]
201 payout_method: Option<String>,
202 #[serde(skip_serializing_if = "Option::is_none")]
203 source_type: Option<CreatePayoutSourceType>,
204 #[serde(skip_serializing_if = "Option::is_none")]
205 statement_descriptor: Option<String>,
206}
207impl CreatePayoutBuilder {
208 fn new(amount: impl Into<i64>, currency: impl Into<stripe_types::Currency>) -> Self {
209 Self {
210 amount: amount.into(),
211 currency: currency.into(),
212 description: None,
213 destination: None,
214 expand: None,
215 metadata: None,
216 method: None,
217 payout_method: None,
218 source_type: None,
219 statement_descriptor: None,
220 }
221 }
222}
223#[derive(Copy, Clone, Eq, PartialEq)]
227pub enum CreatePayoutMethod {
228 Instant,
229 Standard,
230}
231impl CreatePayoutMethod {
232 pub fn as_str(self) -> &'static str {
233 use CreatePayoutMethod::*;
234 match self {
235 Instant => "instant",
236 Standard => "standard",
237 }
238 }
239}
240
241impl std::str::FromStr for CreatePayoutMethod {
242 type Err = stripe_types::StripeParseError;
243 fn from_str(s: &str) -> Result<Self, Self::Err> {
244 use CreatePayoutMethod::*;
245 match s {
246 "instant" => Ok(Instant),
247 "standard" => Ok(Standard),
248 _ => Err(stripe_types::StripeParseError),
249 }
250 }
251}
252impl std::fmt::Display for CreatePayoutMethod {
253 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
254 f.write_str(self.as_str())
255 }
256}
257
258impl std::fmt::Debug for CreatePayoutMethod {
259 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
260 f.write_str(self.as_str())
261 }
262}
263impl serde::Serialize for CreatePayoutMethod {
264 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
265 where
266 S: serde::Serializer,
267 {
268 serializer.serialize_str(self.as_str())
269 }
270}
271#[cfg(feature = "deserialize")]
272impl<'de> serde::Deserialize<'de> for CreatePayoutMethod {
273 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
274 use std::str::FromStr;
275 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
276 Self::from_str(&s)
277 .map_err(|_| serde::de::Error::custom("Unknown value for CreatePayoutMethod"))
278 }
279}
280#[derive(Copy, Clone, Eq, PartialEq)]
285pub enum CreatePayoutSourceType {
286 BankAccount,
287 Card,
288 Fpx,
289}
290impl CreatePayoutSourceType {
291 pub fn as_str(self) -> &'static str {
292 use CreatePayoutSourceType::*;
293 match self {
294 BankAccount => "bank_account",
295 Card => "card",
296 Fpx => "fpx",
297 }
298 }
299}
300
301impl std::str::FromStr for CreatePayoutSourceType {
302 type Err = stripe_types::StripeParseError;
303 fn from_str(s: &str) -> Result<Self, Self::Err> {
304 use CreatePayoutSourceType::*;
305 match s {
306 "bank_account" => Ok(BankAccount),
307 "card" => Ok(Card),
308 "fpx" => Ok(Fpx),
309 _ => Err(stripe_types::StripeParseError),
310 }
311 }
312}
313impl std::fmt::Display for CreatePayoutSourceType {
314 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
315 f.write_str(self.as_str())
316 }
317}
318
319impl std::fmt::Debug for CreatePayoutSourceType {
320 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
321 f.write_str(self.as_str())
322 }
323}
324impl serde::Serialize for CreatePayoutSourceType {
325 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
326 where
327 S: serde::Serializer,
328 {
329 serializer.serialize_str(self.as_str())
330 }
331}
332#[cfg(feature = "deserialize")]
333impl<'de> serde::Deserialize<'de> for CreatePayoutSourceType {
334 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
335 use std::str::FromStr;
336 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
337 Self::from_str(&s)
338 .map_err(|_| serde::de::Error::custom("Unknown value for CreatePayoutSourceType"))
339 }
340}
341#[derive(Clone, Debug, serde::Serialize)]
350pub struct CreatePayout {
351 inner: CreatePayoutBuilder,
352}
353impl CreatePayout {
354 pub fn new(amount: impl Into<i64>, currency: impl Into<stripe_types::Currency>) -> Self {
356 Self { inner: CreatePayoutBuilder::new(amount.into(), currency.into()) }
357 }
358 pub fn description(mut self, description: impl Into<String>) -> Self {
360 self.inner.description = Some(description.into());
361 self
362 }
363 pub fn destination(mut self, destination: impl Into<String>) -> Self {
366 self.inner.destination = Some(destination.into());
367 self
368 }
369 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
371 self.inner.expand = Some(expand.into());
372 self
373 }
374 pub fn metadata(
379 mut self,
380 metadata: impl Into<std::collections::HashMap<String, String>>,
381 ) -> Self {
382 self.inner.metadata = Some(metadata.into());
383 self
384 }
385 pub fn method(mut self, method: impl Into<CreatePayoutMethod>) -> Self {
389 self.inner.method = Some(method.into());
390 self
391 }
392 pub fn payout_method(mut self, payout_method: impl Into<String>) -> Self {
394 self.inner.payout_method = Some(payout_method.into());
395 self
396 }
397 pub fn source_type(mut self, source_type: impl Into<CreatePayoutSourceType>) -> Self {
402 self.inner.source_type = Some(source_type.into());
403 self
404 }
405 pub fn statement_descriptor(mut self, statement_descriptor: impl Into<String>) -> Self {
410 self.inner.statement_descriptor = Some(statement_descriptor.into());
411 self
412 }
413}
414impl CreatePayout {
415 pub async fn send<C: StripeClient>(
417 &self,
418 client: &C,
419 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
420 self.customize().send(client).await
421 }
422
423 pub fn send_blocking<C: StripeBlockingClient>(
425 &self,
426 client: &C,
427 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
428 self.customize().send_blocking(client)
429 }
430}
431
432impl StripeRequest for CreatePayout {
433 type Output = stripe_shared::Payout;
434
435 fn build(&self) -> RequestBuilder {
436 RequestBuilder::new(StripeMethod::Post, "/payouts").form(&self.inner)
437 }
438}
439#[derive(Clone, Debug, serde::Serialize)]
440struct UpdatePayoutBuilder {
441 #[serde(skip_serializing_if = "Option::is_none")]
442 expand: Option<Vec<String>>,
443 #[serde(skip_serializing_if = "Option::is_none")]
444 metadata: Option<std::collections::HashMap<String, String>>,
445}
446impl UpdatePayoutBuilder {
447 fn new() -> Self {
448 Self { expand: None, metadata: None }
449 }
450}
451#[derive(Clone, Debug, serde::Serialize)]
455pub struct UpdatePayout {
456 inner: UpdatePayoutBuilder,
457 payout: stripe_shared::PayoutId,
458}
459impl UpdatePayout {
460 pub fn new(payout: impl Into<stripe_shared::PayoutId>) -> Self {
462 Self { payout: payout.into(), inner: UpdatePayoutBuilder::new() }
463 }
464 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
466 self.inner.expand = Some(expand.into());
467 self
468 }
469 pub fn metadata(
474 mut self,
475 metadata: impl Into<std::collections::HashMap<String, String>>,
476 ) -> Self {
477 self.inner.metadata = Some(metadata.into());
478 self
479 }
480}
481impl UpdatePayout {
482 pub async fn send<C: StripeClient>(
484 &self,
485 client: &C,
486 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
487 self.customize().send(client).await
488 }
489
490 pub fn send_blocking<C: StripeBlockingClient>(
492 &self,
493 client: &C,
494 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
495 self.customize().send_blocking(client)
496 }
497}
498
499impl StripeRequest for UpdatePayout {
500 type Output = stripe_shared::Payout;
501
502 fn build(&self) -> RequestBuilder {
503 let payout = &self.payout;
504 RequestBuilder::new(StripeMethod::Post, format!("/payouts/{payout}")).form(&self.inner)
505 }
506}
507#[derive(Clone, Debug, serde::Serialize)]
508struct CancelPayoutBuilder {
509 #[serde(skip_serializing_if = "Option::is_none")]
510 expand: Option<Vec<String>>,
511}
512impl CancelPayoutBuilder {
513 fn new() -> Self {
514 Self { expand: None }
515 }
516}
517#[derive(Clone, Debug, serde::Serialize)]
521pub struct CancelPayout {
522 inner: CancelPayoutBuilder,
523 payout: stripe_shared::PayoutId,
524}
525impl CancelPayout {
526 pub fn new(payout: impl Into<stripe_shared::PayoutId>) -> Self {
528 Self { payout: payout.into(), inner: CancelPayoutBuilder::new() }
529 }
530 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
532 self.inner.expand = Some(expand.into());
533 self
534 }
535}
536impl CancelPayout {
537 pub async fn send<C: StripeClient>(
539 &self,
540 client: &C,
541 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
542 self.customize().send(client).await
543 }
544
545 pub fn send_blocking<C: StripeBlockingClient>(
547 &self,
548 client: &C,
549 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
550 self.customize().send_blocking(client)
551 }
552}
553
554impl StripeRequest for CancelPayout {
555 type Output = stripe_shared::Payout;
556
557 fn build(&self) -> RequestBuilder {
558 let payout = &self.payout;
559 RequestBuilder::new(StripeMethod::Post, format!("/payouts/{payout}/cancel"))
560 .form(&self.inner)
561 }
562}
563#[derive(Clone, Debug, serde::Serialize)]
564struct ReversePayoutBuilder {
565 #[serde(skip_serializing_if = "Option::is_none")]
566 expand: Option<Vec<String>>,
567 #[serde(skip_serializing_if = "Option::is_none")]
568 metadata: Option<std::collections::HashMap<String, String>>,
569}
570impl ReversePayoutBuilder {
571 fn new() -> Self {
572 Self { expand: None, metadata: None }
573 }
574}
575#[derive(Clone, Debug, serde::Serialize)]
581pub struct ReversePayout {
582 inner: ReversePayoutBuilder,
583 payout: stripe_shared::PayoutId,
584}
585impl ReversePayout {
586 pub fn new(payout: impl Into<stripe_shared::PayoutId>) -> Self {
588 Self { payout: payout.into(), inner: ReversePayoutBuilder::new() }
589 }
590 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
592 self.inner.expand = Some(expand.into());
593 self
594 }
595 pub fn metadata(
600 mut self,
601 metadata: impl Into<std::collections::HashMap<String, String>>,
602 ) -> Self {
603 self.inner.metadata = Some(metadata.into());
604 self
605 }
606}
607impl ReversePayout {
608 pub async fn send<C: StripeClient>(
610 &self,
611 client: &C,
612 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
613 self.customize().send(client).await
614 }
615
616 pub fn send_blocking<C: StripeBlockingClient>(
618 &self,
619 client: &C,
620 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
621 self.customize().send_blocking(client)
622 }
623}
624
625impl StripeRequest for ReversePayout {
626 type Output = stripe_shared::Payout;
627
628 fn build(&self) -> RequestBuilder {
629 let payout = &self.payout;
630 RequestBuilder::new(StripeMethod::Post, format!("/payouts/{payout}/reverse"))
631 .form(&self.inner)
632 }
633}