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(Clone, Eq, PartialEq)]
227#[non_exhaustive]
228pub enum CreatePayoutMethod {
229 Instant,
230 Standard,
231 Unknown(String),
233}
234impl CreatePayoutMethod {
235 pub fn as_str(&self) -> &str {
236 use CreatePayoutMethod::*;
237 match self {
238 Instant => "instant",
239 Standard => "standard",
240 Unknown(v) => v,
241 }
242 }
243}
244
245impl std::str::FromStr for CreatePayoutMethod {
246 type Err = std::convert::Infallible;
247 fn from_str(s: &str) -> Result<Self, Self::Err> {
248 use CreatePayoutMethod::*;
249 match s {
250 "instant" => Ok(Instant),
251 "standard" => Ok(Standard),
252 v => {
253 tracing::warn!("Unknown value '{}' for enum '{}'", v, "CreatePayoutMethod");
254 Ok(Unknown(v.to_owned()))
255 }
256 }
257 }
258}
259impl std::fmt::Display for CreatePayoutMethod {
260 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
261 f.write_str(self.as_str())
262 }
263}
264
265impl std::fmt::Debug for CreatePayoutMethod {
266 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
267 f.write_str(self.as_str())
268 }
269}
270impl serde::Serialize for CreatePayoutMethod {
271 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
272 where
273 S: serde::Serializer,
274 {
275 serializer.serialize_str(self.as_str())
276 }
277}
278#[cfg(feature = "deserialize")]
279impl<'de> serde::Deserialize<'de> for CreatePayoutMethod {
280 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
281 use std::str::FromStr;
282 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
283 Ok(Self::from_str(&s).expect("infallible"))
284 }
285}
286#[derive(Clone, Eq, PartialEq)]
291#[non_exhaustive]
292pub enum CreatePayoutSourceType {
293 BankAccount,
294 Card,
295 Fpx,
296 Unknown(String),
298}
299impl CreatePayoutSourceType {
300 pub fn as_str(&self) -> &str {
301 use CreatePayoutSourceType::*;
302 match self {
303 BankAccount => "bank_account",
304 Card => "card",
305 Fpx => "fpx",
306 Unknown(v) => v,
307 }
308 }
309}
310
311impl std::str::FromStr for CreatePayoutSourceType {
312 type Err = std::convert::Infallible;
313 fn from_str(s: &str) -> Result<Self, Self::Err> {
314 use CreatePayoutSourceType::*;
315 match s {
316 "bank_account" => Ok(BankAccount),
317 "card" => Ok(Card),
318 "fpx" => Ok(Fpx),
319 v => {
320 tracing::warn!("Unknown value '{}' for enum '{}'", v, "CreatePayoutSourceType");
321 Ok(Unknown(v.to_owned()))
322 }
323 }
324 }
325}
326impl std::fmt::Display for CreatePayoutSourceType {
327 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
328 f.write_str(self.as_str())
329 }
330}
331
332impl std::fmt::Debug for CreatePayoutSourceType {
333 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
334 f.write_str(self.as_str())
335 }
336}
337impl serde::Serialize for CreatePayoutSourceType {
338 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
339 where
340 S: serde::Serializer,
341 {
342 serializer.serialize_str(self.as_str())
343 }
344}
345#[cfg(feature = "deserialize")]
346impl<'de> serde::Deserialize<'de> for CreatePayoutSourceType {
347 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
348 use std::str::FromStr;
349 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
350 Ok(Self::from_str(&s).expect("infallible"))
351 }
352}
353#[derive(Clone, Debug, serde::Serialize)]
362pub struct CreatePayout {
363 inner: CreatePayoutBuilder,
364}
365impl CreatePayout {
366 pub fn new(amount: impl Into<i64>, currency: impl Into<stripe_types::Currency>) -> Self {
368 Self { inner: CreatePayoutBuilder::new(amount.into(), currency.into()) }
369 }
370 pub fn description(mut self, description: impl Into<String>) -> Self {
372 self.inner.description = Some(description.into());
373 self
374 }
375 pub fn destination(mut self, destination: impl Into<String>) -> Self {
378 self.inner.destination = Some(destination.into());
379 self
380 }
381 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
383 self.inner.expand = Some(expand.into());
384 self
385 }
386 pub fn metadata(
391 mut self,
392 metadata: impl Into<std::collections::HashMap<String, String>>,
393 ) -> Self {
394 self.inner.metadata = Some(metadata.into());
395 self
396 }
397 pub fn method(mut self, method: impl Into<CreatePayoutMethod>) -> Self {
401 self.inner.method = Some(method.into());
402 self
403 }
404 pub fn payout_method(mut self, payout_method: impl Into<String>) -> Self {
406 self.inner.payout_method = Some(payout_method.into());
407 self
408 }
409 pub fn source_type(mut self, source_type: impl Into<CreatePayoutSourceType>) -> Self {
414 self.inner.source_type = Some(source_type.into());
415 self
416 }
417 pub fn statement_descriptor(mut self, statement_descriptor: impl Into<String>) -> Self {
422 self.inner.statement_descriptor = Some(statement_descriptor.into());
423 self
424 }
425}
426impl CreatePayout {
427 pub async fn send<C: StripeClient>(
429 &self,
430 client: &C,
431 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
432 self.customize().send(client).await
433 }
434
435 pub fn send_blocking<C: StripeBlockingClient>(
437 &self,
438 client: &C,
439 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
440 self.customize().send_blocking(client)
441 }
442}
443
444impl StripeRequest for CreatePayout {
445 type Output = stripe_shared::Payout;
446
447 fn build(&self) -> RequestBuilder {
448 RequestBuilder::new(StripeMethod::Post, "/payouts").form(&self.inner)
449 }
450}
451#[derive(Clone, Debug, serde::Serialize)]
452struct UpdatePayoutBuilder {
453 #[serde(skip_serializing_if = "Option::is_none")]
454 expand: Option<Vec<String>>,
455 #[serde(skip_serializing_if = "Option::is_none")]
456 metadata: Option<std::collections::HashMap<String, String>>,
457}
458impl UpdatePayoutBuilder {
459 fn new() -> Self {
460 Self { expand: None, metadata: None }
461 }
462}
463#[derive(Clone, Debug, serde::Serialize)]
467pub struct UpdatePayout {
468 inner: UpdatePayoutBuilder,
469 payout: stripe_shared::PayoutId,
470}
471impl UpdatePayout {
472 pub fn new(payout: impl Into<stripe_shared::PayoutId>) -> Self {
474 Self { payout: payout.into(), inner: UpdatePayoutBuilder::new() }
475 }
476 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
478 self.inner.expand = Some(expand.into());
479 self
480 }
481 pub fn metadata(
486 mut self,
487 metadata: impl Into<std::collections::HashMap<String, String>>,
488 ) -> Self {
489 self.inner.metadata = Some(metadata.into());
490 self
491 }
492}
493impl UpdatePayout {
494 pub async fn send<C: StripeClient>(
496 &self,
497 client: &C,
498 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
499 self.customize().send(client).await
500 }
501
502 pub fn send_blocking<C: StripeBlockingClient>(
504 &self,
505 client: &C,
506 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
507 self.customize().send_blocking(client)
508 }
509}
510
511impl StripeRequest for UpdatePayout {
512 type Output = stripe_shared::Payout;
513
514 fn build(&self) -> RequestBuilder {
515 let payout = &self.payout;
516 RequestBuilder::new(StripeMethod::Post, format!("/payouts/{payout}")).form(&self.inner)
517 }
518}
519#[derive(Clone, Debug, serde::Serialize)]
520struct CancelPayoutBuilder {
521 #[serde(skip_serializing_if = "Option::is_none")]
522 expand: Option<Vec<String>>,
523}
524impl CancelPayoutBuilder {
525 fn new() -> Self {
526 Self { expand: None }
527 }
528}
529#[derive(Clone, Debug, serde::Serialize)]
533pub struct CancelPayout {
534 inner: CancelPayoutBuilder,
535 payout: stripe_shared::PayoutId,
536}
537impl CancelPayout {
538 pub fn new(payout: impl Into<stripe_shared::PayoutId>) -> Self {
540 Self { payout: payout.into(), inner: CancelPayoutBuilder::new() }
541 }
542 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
544 self.inner.expand = Some(expand.into());
545 self
546 }
547}
548impl CancelPayout {
549 pub async fn send<C: StripeClient>(
551 &self,
552 client: &C,
553 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
554 self.customize().send(client).await
555 }
556
557 pub fn send_blocking<C: StripeBlockingClient>(
559 &self,
560 client: &C,
561 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
562 self.customize().send_blocking(client)
563 }
564}
565
566impl StripeRequest for CancelPayout {
567 type Output = stripe_shared::Payout;
568
569 fn build(&self) -> RequestBuilder {
570 let payout = &self.payout;
571 RequestBuilder::new(StripeMethod::Post, format!("/payouts/{payout}/cancel"))
572 .form(&self.inner)
573 }
574}
575#[derive(Clone, Debug, serde::Serialize)]
576struct ReversePayoutBuilder {
577 #[serde(skip_serializing_if = "Option::is_none")]
578 expand: Option<Vec<String>>,
579 #[serde(skip_serializing_if = "Option::is_none")]
580 metadata: Option<std::collections::HashMap<String, String>>,
581}
582impl ReversePayoutBuilder {
583 fn new() -> Self {
584 Self { expand: None, metadata: None }
585 }
586}
587#[derive(Clone, Debug, serde::Serialize)]
593pub struct ReversePayout {
594 inner: ReversePayoutBuilder,
595 payout: stripe_shared::PayoutId,
596}
597impl ReversePayout {
598 pub fn new(payout: impl Into<stripe_shared::PayoutId>) -> Self {
600 Self { payout: payout.into(), inner: ReversePayoutBuilder::new() }
601 }
602 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
604 self.inner.expand = Some(expand.into());
605 self
606 }
607 pub fn metadata(
612 mut self,
613 metadata: impl Into<std::collections::HashMap<String, String>>,
614 ) -> Self {
615 self.inner.metadata = Some(metadata.into());
616 self
617 }
618}
619impl ReversePayout {
620 pub async fn send<C: StripeClient>(
622 &self,
623 client: &C,
624 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
625 self.customize().send(client).await
626 }
627
628 pub fn send_blocking<C: StripeBlockingClient>(
630 &self,
631 client: &C,
632 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
633 self.customize().send_blocking(client)
634 }
635}
636
637impl StripeRequest for ReversePayout {
638 type Output = stripe_shared::Payout;
639
640 fn build(&self) -> RequestBuilder {
641 let payout = &self.payout;
642 RequestBuilder::new(StripeMethod::Post, format!("/payouts/{payout}/reverse"))
643 .form(&self.inner)
644 }
645}