Skip to main content

stripe_treasury/treasury_outbound_transfer/
requests.rs

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 ListTreasuryOutboundTransferBuilder {
9    #[serde(skip_serializing_if = "Option::is_none")]
10    ending_before: Option<String>,
11    #[serde(skip_serializing_if = "Option::is_none")]
12    expand: Option<Vec<String>>,
13    financial_account: String,
14    #[serde(skip_serializing_if = "Option::is_none")]
15    limit: Option<i64>,
16    #[serde(skip_serializing_if = "Option::is_none")]
17    starting_after: Option<String>,
18    #[serde(skip_serializing_if = "Option::is_none")]
19    status: Option<stripe_treasury::TreasuryOutboundTransferStatus>,
20}
21#[cfg(feature = "redact-generated-debug")]
22impl std::fmt::Debug for ListTreasuryOutboundTransferBuilder {
23    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
24        f.debug_struct("ListTreasuryOutboundTransferBuilder").finish_non_exhaustive()
25    }
26}
27impl ListTreasuryOutboundTransferBuilder {
28    fn new(financial_account: impl Into<String>) -> Self {
29        Self {
30            ending_before: None,
31            expand: None,
32            financial_account: financial_account.into(),
33            limit: None,
34            starting_after: None,
35            status: None,
36        }
37    }
38}
39/// Returns a list of OutboundTransfers sent from the specified FinancialAccount.
40#[derive(Clone)]
41#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
42#[derive(serde::Serialize)]
43pub struct ListTreasuryOutboundTransfer {
44    inner: ListTreasuryOutboundTransferBuilder,
45}
46#[cfg(feature = "redact-generated-debug")]
47impl std::fmt::Debug for ListTreasuryOutboundTransfer {
48    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
49        f.debug_struct("ListTreasuryOutboundTransfer").finish_non_exhaustive()
50    }
51}
52impl ListTreasuryOutboundTransfer {
53    /// Construct a new `ListTreasuryOutboundTransfer`.
54    pub fn new(financial_account: impl Into<String>) -> Self {
55        Self { inner: ListTreasuryOutboundTransferBuilder::new(financial_account.into()) }
56    }
57    /// A cursor for use in pagination.
58    /// `ending_before` is an object ID that defines your place in the list.
59    /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
60    pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
61        self.inner.ending_before = Some(ending_before.into());
62        self
63    }
64    /// Specifies which fields in the response should be expanded.
65    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
66        self.inner.expand = Some(expand.into());
67        self
68    }
69    /// A limit on the number of objects to be returned.
70    /// Limit can range between 1 and 100, and the default is 10.
71    pub fn limit(mut self, limit: impl Into<i64>) -> Self {
72        self.inner.limit = Some(limit.into());
73        self
74    }
75    /// A cursor for use in pagination.
76    /// `starting_after` is an object ID that defines your place in the list.
77    /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
78    pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
79        self.inner.starting_after = Some(starting_after.into());
80        self
81    }
82    /// Only return OutboundTransfers that have the given status: `processing`, `canceled`, `failed`, `posted`, or `returned`.
83    pub fn status(
84        mut self,
85        status: impl Into<stripe_treasury::TreasuryOutboundTransferStatus>,
86    ) -> Self {
87        self.inner.status = Some(status.into());
88        self
89    }
90}
91impl ListTreasuryOutboundTransfer {
92    /// Send the request and return the deserialized response.
93    pub async fn send<C: StripeClient>(
94        &self,
95        client: &C,
96    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
97        self.customize().send(client).await
98    }
99
100    /// Send the request and return the deserialized response, blocking until completion.
101    pub fn send_blocking<C: StripeBlockingClient>(
102        &self,
103        client: &C,
104    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
105        self.customize().send_blocking(client)
106    }
107
108    pub fn paginate(
109        &self,
110    ) -> stripe_client_core::ListPaginator<
111        stripe_types::List<stripe_treasury::TreasuryOutboundTransfer>,
112    > {
113        stripe_client_core::ListPaginator::new_list("/treasury/outbound_transfers", &self.inner)
114    }
115}
116
117impl StripeRequest for ListTreasuryOutboundTransfer {
118    type Output = stripe_types::List<stripe_treasury::TreasuryOutboundTransfer>;
119
120    fn build(&self) -> RequestBuilder {
121        RequestBuilder::new(StripeMethod::Get, "/treasury/outbound_transfers").query(&self.inner)
122    }
123}
124#[derive(Clone, Eq, PartialEq)]
125#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
126#[derive(serde::Serialize)]
127struct RetrieveTreasuryOutboundTransferBuilder {
128    #[serde(skip_serializing_if = "Option::is_none")]
129    expand: Option<Vec<String>>,
130}
131#[cfg(feature = "redact-generated-debug")]
132impl std::fmt::Debug for RetrieveTreasuryOutboundTransferBuilder {
133    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
134        f.debug_struct("RetrieveTreasuryOutboundTransferBuilder").finish_non_exhaustive()
135    }
136}
137impl RetrieveTreasuryOutboundTransferBuilder {
138    fn new() -> Self {
139        Self { expand: None }
140    }
141}
142/// Retrieves the details of an existing OutboundTransfer by passing the unique OutboundTransfer ID from either the OutboundTransfer creation request or OutboundTransfer list.
143#[derive(Clone)]
144#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
145#[derive(serde::Serialize)]
146pub struct RetrieveTreasuryOutboundTransfer {
147    inner: RetrieveTreasuryOutboundTransferBuilder,
148    outbound_transfer: stripe_treasury::TreasuryOutboundTransferId,
149}
150#[cfg(feature = "redact-generated-debug")]
151impl std::fmt::Debug for RetrieveTreasuryOutboundTransfer {
152    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
153        f.debug_struct("RetrieveTreasuryOutboundTransfer").finish_non_exhaustive()
154    }
155}
156impl RetrieveTreasuryOutboundTransfer {
157    /// Construct a new `RetrieveTreasuryOutboundTransfer`.
158    pub fn new(outbound_transfer: impl Into<stripe_treasury::TreasuryOutboundTransferId>) -> Self {
159        Self {
160            outbound_transfer: outbound_transfer.into(),
161            inner: RetrieveTreasuryOutboundTransferBuilder::new(),
162        }
163    }
164    /// Specifies which fields in the response should be expanded.
165    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
166        self.inner.expand = Some(expand.into());
167        self
168    }
169}
170impl RetrieveTreasuryOutboundTransfer {
171    /// Send the request and return the deserialized response.
172    pub async fn send<C: StripeClient>(
173        &self,
174        client: &C,
175    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
176        self.customize().send(client).await
177    }
178
179    /// Send the request and return the deserialized response, blocking until completion.
180    pub fn send_blocking<C: StripeBlockingClient>(
181        &self,
182        client: &C,
183    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
184        self.customize().send_blocking(client)
185    }
186}
187
188impl StripeRequest for RetrieveTreasuryOutboundTransfer {
189    type Output = stripe_treasury::TreasuryOutboundTransfer;
190
191    fn build(&self) -> RequestBuilder {
192        let outbound_transfer = &self.outbound_transfer;
193        RequestBuilder::new(
194            StripeMethod::Get,
195            format!("/treasury/outbound_transfers/{outbound_transfer}"),
196        )
197        .query(&self.inner)
198    }
199}
200#[derive(Clone, Eq, PartialEq)]
201#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
202#[derive(serde::Serialize)]
203struct UpdateTreasuryOutboundTransferBuilder {
204    #[serde(skip_serializing_if = "Option::is_none")]
205    expand: Option<Vec<String>>,
206    tracking_details: UpdateTreasuryOutboundTransferTrackingDetails,
207}
208#[cfg(feature = "redact-generated-debug")]
209impl std::fmt::Debug for UpdateTreasuryOutboundTransferBuilder {
210    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
211        f.debug_struct("UpdateTreasuryOutboundTransferBuilder").finish_non_exhaustive()
212    }
213}
214impl UpdateTreasuryOutboundTransferBuilder {
215    fn new(tracking_details: impl Into<UpdateTreasuryOutboundTransferTrackingDetails>) -> Self {
216        Self { expand: None, tracking_details: tracking_details.into() }
217    }
218}
219/// Details about network-specific tracking information.
220#[derive(Clone, Eq, PartialEq)]
221#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
222#[derive(serde::Serialize)]
223pub struct UpdateTreasuryOutboundTransferTrackingDetails {
224    /// ACH network tracking details.
225    #[serde(skip_serializing_if = "Option::is_none")]
226    pub ach: Option<UpdateTreasuryOutboundTransferTrackingDetailsAch>,
227    /// The US bank account network used to send funds.
228    #[serde(rename = "type")]
229    pub type_: UpdateTreasuryOutboundTransferTrackingDetailsType,
230    /// US domestic wire network tracking details.
231    #[serde(skip_serializing_if = "Option::is_none")]
232    pub us_domestic_wire: Option<UpdateTreasuryOutboundTransferTrackingDetailsUsDomesticWire>,
233}
234#[cfg(feature = "redact-generated-debug")]
235impl std::fmt::Debug for UpdateTreasuryOutboundTransferTrackingDetails {
236    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
237        f.debug_struct("UpdateTreasuryOutboundTransferTrackingDetails").finish_non_exhaustive()
238    }
239}
240impl UpdateTreasuryOutboundTransferTrackingDetails {
241    pub fn new(type_: impl Into<UpdateTreasuryOutboundTransferTrackingDetailsType>) -> Self {
242        Self { ach: None, type_: type_.into(), us_domestic_wire: None }
243    }
244}
245/// ACH network tracking details.
246#[derive(Clone, Eq, PartialEq)]
247#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
248#[derive(serde::Serialize)]
249pub struct UpdateTreasuryOutboundTransferTrackingDetailsAch {
250    /// ACH trace ID for funds sent over the `ach` network.
251    pub trace_id: String,
252}
253#[cfg(feature = "redact-generated-debug")]
254impl std::fmt::Debug for UpdateTreasuryOutboundTransferTrackingDetailsAch {
255    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
256        f.debug_struct("UpdateTreasuryOutboundTransferTrackingDetailsAch").finish_non_exhaustive()
257    }
258}
259impl UpdateTreasuryOutboundTransferTrackingDetailsAch {
260    pub fn new(trace_id: impl Into<String>) -> Self {
261        Self { trace_id: trace_id.into() }
262    }
263}
264/// The US bank account network used to send funds.
265#[derive(Clone, Eq, PartialEq)]
266#[non_exhaustive]
267pub enum UpdateTreasuryOutboundTransferTrackingDetailsType {
268    Ach,
269    UsDomesticWire,
270    /// An unrecognized value from Stripe. Should not be used as a request parameter.
271    Unknown(String),
272}
273impl UpdateTreasuryOutboundTransferTrackingDetailsType {
274    pub fn as_str(&self) -> &str {
275        use UpdateTreasuryOutboundTransferTrackingDetailsType::*;
276        match self {
277            Ach => "ach",
278            UsDomesticWire => "us_domestic_wire",
279            Unknown(v) => v,
280        }
281    }
282}
283
284impl std::str::FromStr for UpdateTreasuryOutboundTransferTrackingDetailsType {
285    type Err = std::convert::Infallible;
286    fn from_str(s: &str) -> Result<Self, Self::Err> {
287        use UpdateTreasuryOutboundTransferTrackingDetailsType::*;
288        match s {
289            "ach" => Ok(Ach),
290            "us_domestic_wire" => Ok(UsDomesticWire),
291            v => {
292                tracing::warn!(
293                    "Unknown value '{}' for enum '{}'",
294                    v,
295                    "UpdateTreasuryOutboundTransferTrackingDetailsType"
296                );
297                Ok(Unknown(v.to_owned()))
298            }
299        }
300    }
301}
302impl std::fmt::Display for UpdateTreasuryOutboundTransferTrackingDetailsType {
303    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
304        f.write_str(self.as_str())
305    }
306}
307
308#[cfg(not(feature = "redact-generated-debug"))]
309impl std::fmt::Debug for UpdateTreasuryOutboundTransferTrackingDetailsType {
310    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
311        f.write_str(self.as_str())
312    }
313}
314#[cfg(feature = "redact-generated-debug")]
315impl std::fmt::Debug for UpdateTreasuryOutboundTransferTrackingDetailsType {
316    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
317        f.debug_struct(stringify!(UpdateTreasuryOutboundTransferTrackingDetailsType))
318            .finish_non_exhaustive()
319    }
320}
321impl serde::Serialize for UpdateTreasuryOutboundTransferTrackingDetailsType {
322    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
323    where
324        S: serde::Serializer,
325    {
326        serializer.serialize_str(self.as_str())
327    }
328}
329#[cfg(feature = "deserialize")]
330impl<'de> serde::Deserialize<'de> for UpdateTreasuryOutboundTransferTrackingDetailsType {
331    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
332        use std::str::FromStr;
333        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
334        Ok(Self::from_str(&s).expect("infallible"))
335    }
336}
337/// US domestic wire network tracking details.
338#[derive(Clone, Eq, PartialEq)]
339#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
340#[derive(serde::Serialize)]
341pub struct UpdateTreasuryOutboundTransferTrackingDetailsUsDomesticWire {
342    /// CHIPS System Sequence Number (SSN) for funds sent over the `us_domestic_wire` network.
343    #[serde(skip_serializing_if = "Option::is_none")]
344    pub chips: Option<String>,
345    /// IMAD for funds sent over the `us_domestic_wire` network.
346    #[serde(skip_serializing_if = "Option::is_none")]
347    pub imad: Option<String>,
348    /// OMAD for funds sent over the `us_domestic_wire` network.
349    #[serde(skip_serializing_if = "Option::is_none")]
350    pub omad: Option<String>,
351}
352#[cfg(feature = "redact-generated-debug")]
353impl std::fmt::Debug for UpdateTreasuryOutboundTransferTrackingDetailsUsDomesticWire {
354    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
355        f.debug_struct("UpdateTreasuryOutboundTransferTrackingDetailsUsDomesticWire")
356            .finish_non_exhaustive()
357    }
358}
359impl UpdateTreasuryOutboundTransferTrackingDetailsUsDomesticWire {
360    pub fn new() -> Self {
361        Self { chips: None, imad: None, omad: None }
362    }
363}
364impl Default for UpdateTreasuryOutboundTransferTrackingDetailsUsDomesticWire {
365    fn default() -> Self {
366        Self::new()
367    }
368}
369/// Updates a test mode created OutboundTransfer with tracking details.
370/// The OutboundTransfer must not be cancelable, and cannot be in the `canceled` or `failed` states.
371#[derive(Clone)]
372#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
373#[derive(serde::Serialize)]
374pub struct UpdateTreasuryOutboundTransfer {
375    inner: UpdateTreasuryOutboundTransferBuilder,
376    outbound_transfer: String,
377}
378#[cfg(feature = "redact-generated-debug")]
379impl std::fmt::Debug for UpdateTreasuryOutboundTransfer {
380    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
381        f.debug_struct("UpdateTreasuryOutboundTransfer").finish_non_exhaustive()
382    }
383}
384impl UpdateTreasuryOutboundTransfer {
385    /// Construct a new `UpdateTreasuryOutboundTransfer`.
386    pub fn new(
387        outbound_transfer: impl Into<String>,
388        tracking_details: impl Into<UpdateTreasuryOutboundTransferTrackingDetails>,
389    ) -> Self {
390        Self {
391            outbound_transfer: outbound_transfer.into(),
392            inner: UpdateTreasuryOutboundTransferBuilder::new(tracking_details.into()),
393        }
394    }
395    /// Specifies which fields in the response should be expanded.
396    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
397        self.inner.expand = Some(expand.into());
398        self
399    }
400}
401impl UpdateTreasuryOutboundTransfer {
402    /// Send the request and return the deserialized response.
403    pub async fn send<C: StripeClient>(
404        &self,
405        client: &C,
406    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
407        self.customize().send(client).await
408    }
409
410    /// Send the request and return the deserialized response, blocking until completion.
411    pub fn send_blocking<C: StripeBlockingClient>(
412        &self,
413        client: &C,
414    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
415        self.customize().send_blocking(client)
416    }
417}
418
419impl StripeRequest for UpdateTreasuryOutboundTransfer {
420    type Output = stripe_treasury::TreasuryOutboundTransfer;
421
422    fn build(&self) -> RequestBuilder {
423        let outbound_transfer = &self.outbound_transfer;
424        RequestBuilder::new(
425            StripeMethod::Post,
426            format!("/test_helpers/treasury/outbound_transfers/{outbound_transfer}"),
427        )
428        .form(&self.inner)
429    }
430}
431#[derive(Clone, Eq, PartialEq)]
432#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
433#[derive(serde::Serialize)]
434struct FailTreasuryOutboundTransferBuilder {
435    #[serde(skip_serializing_if = "Option::is_none")]
436    expand: Option<Vec<String>>,
437}
438#[cfg(feature = "redact-generated-debug")]
439impl std::fmt::Debug for FailTreasuryOutboundTransferBuilder {
440    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
441        f.debug_struct("FailTreasuryOutboundTransferBuilder").finish_non_exhaustive()
442    }
443}
444impl FailTreasuryOutboundTransferBuilder {
445    fn new() -> Self {
446        Self { expand: None }
447    }
448}
449/// Transitions a test mode created OutboundTransfer to the `failed` status.
450/// The OutboundTransfer must already be in the `processing` state.
451#[derive(Clone)]
452#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
453#[derive(serde::Serialize)]
454pub struct FailTreasuryOutboundTransfer {
455    inner: FailTreasuryOutboundTransferBuilder,
456    outbound_transfer: String,
457}
458#[cfg(feature = "redact-generated-debug")]
459impl std::fmt::Debug for FailTreasuryOutboundTransfer {
460    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
461        f.debug_struct("FailTreasuryOutboundTransfer").finish_non_exhaustive()
462    }
463}
464impl FailTreasuryOutboundTransfer {
465    /// Construct a new `FailTreasuryOutboundTransfer`.
466    pub fn new(outbound_transfer: impl Into<String>) -> Self {
467        Self {
468            outbound_transfer: outbound_transfer.into(),
469            inner: FailTreasuryOutboundTransferBuilder::new(),
470        }
471    }
472    /// Specifies which fields in the response should be expanded.
473    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
474        self.inner.expand = Some(expand.into());
475        self
476    }
477}
478impl FailTreasuryOutboundTransfer {
479    /// Send the request and return the deserialized response.
480    pub async fn send<C: StripeClient>(
481        &self,
482        client: &C,
483    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
484        self.customize().send(client).await
485    }
486
487    /// Send the request and return the deserialized response, blocking until completion.
488    pub fn send_blocking<C: StripeBlockingClient>(
489        &self,
490        client: &C,
491    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
492        self.customize().send_blocking(client)
493    }
494}
495
496impl StripeRequest for FailTreasuryOutboundTransfer {
497    type Output = stripe_treasury::TreasuryOutboundTransfer;
498
499    fn build(&self) -> RequestBuilder {
500        let outbound_transfer = &self.outbound_transfer;
501        RequestBuilder::new(
502            StripeMethod::Post,
503            format!("/test_helpers/treasury/outbound_transfers/{outbound_transfer}/fail"),
504        )
505        .form(&self.inner)
506    }
507}
508#[derive(Clone, Eq, PartialEq)]
509#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
510#[derive(serde::Serialize)]
511struct PostTreasuryOutboundTransferBuilder {
512    #[serde(skip_serializing_if = "Option::is_none")]
513    expand: Option<Vec<String>>,
514}
515#[cfg(feature = "redact-generated-debug")]
516impl std::fmt::Debug for PostTreasuryOutboundTransferBuilder {
517    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
518        f.debug_struct("PostTreasuryOutboundTransferBuilder").finish_non_exhaustive()
519    }
520}
521impl PostTreasuryOutboundTransferBuilder {
522    fn new() -> Self {
523        Self { expand: None }
524    }
525}
526/// Transitions a test mode created OutboundTransfer to the `posted` status.
527/// The OutboundTransfer must already be in the `processing` state.
528#[derive(Clone)]
529#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
530#[derive(serde::Serialize)]
531pub struct PostTreasuryOutboundTransfer {
532    inner: PostTreasuryOutboundTransferBuilder,
533    outbound_transfer: String,
534}
535#[cfg(feature = "redact-generated-debug")]
536impl std::fmt::Debug for PostTreasuryOutboundTransfer {
537    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
538        f.debug_struct("PostTreasuryOutboundTransfer").finish_non_exhaustive()
539    }
540}
541impl PostTreasuryOutboundTransfer {
542    /// Construct a new `PostTreasuryOutboundTransfer`.
543    pub fn new(outbound_transfer: impl Into<String>) -> Self {
544        Self {
545            outbound_transfer: outbound_transfer.into(),
546            inner: PostTreasuryOutboundTransferBuilder::new(),
547        }
548    }
549    /// Specifies which fields in the response should be expanded.
550    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
551        self.inner.expand = Some(expand.into());
552        self
553    }
554}
555impl PostTreasuryOutboundTransfer {
556    /// Send the request and return the deserialized response.
557    pub async fn send<C: StripeClient>(
558        &self,
559        client: &C,
560    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
561        self.customize().send(client).await
562    }
563
564    /// Send the request and return the deserialized response, blocking until completion.
565    pub fn send_blocking<C: StripeBlockingClient>(
566        &self,
567        client: &C,
568    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
569        self.customize().send_blocking(client)
570    }
571}
572
573impl StripeRequest for PostTreasuryOutboundTransfer {
574    type Output = stripe_treasury::TreasuryOutboundTransfer;
575
576    fn build(&self) -> RequestBuilder {
577        let outbound_transfer = &self.outbound_transfer;
578        RequestBuilder::new(
579            StripeMethod::Post,
580            format!("/test_helpers/treasury/outbound_transfers/{outbound_transfer}/post"),
581        )
582        .form(&self.inner)
583    }
584}
585#[derive(Clone, Eq, PartialEq)]
586#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
587#[derive(serde::Serialize)]
588struct ReturnOutboundTransferTreasuryOutboundTransferBuilder {
589    #[serde(skip_serializing_if = "Option::is_none")]
590    expand: Option<Vec<String>>,
591    #[serde(skip_serializing_if = "Option::is_none")]
592    returned_details: Option<ReturnOutboundTransferTreasuryOutboundTransferReturnedDetails>,
593}
594#[cfg(feature = "redact-generated-debug")]
595impl std::fmt::Debug for ReturnOutboundTransferTreasuryOutboundTransferBuilder {
596    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
597        f.debug_struct("ReturnOutboundTransferTreasuryOutboundTransferBuilder")
598            .finish_non_exhaustive()
599    }
600}
601impl ReturnOutboundTransferTreasuryOutboundTransferBuilder {
602    fn new() -> Self {
603        Self { expand: None, returned_details: None }
604    }
605}
606/// Details about a returned OutboundTransfer.
607#[derive(Clone, Eq, PartialEq)]
608#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
609#[derive(serde::Serialize)]
610pub struct ReturnOutboundTransferTreasuryOutboundTransferReturnedDetails {
611    /// Reason for the return.
612    #[serde(skip_serializing_if = "Option::is_none")]
613    pub code: Option<ReturnOutboundTransferTreasuryOutboundTransferReturnedDetailsCode>,
614}
615#[cfg(feature = "redact-generated-debug")]
616impl std::fmt::Debug for ReturnOutboundTransferTreasuryOutboundTransferReturnedDetails {
617    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
618        f.debug_struct("ReturnOutboundTransferTreasuryOutboundTransferReturnedDetails")
619            .finish_non_exhaustive()
620    }
621}
622impl ReturnOutboundTransferTreasuryOutboundTransferReturnedDetails {
623    pub fn new() -> Self {
624        Self { code: None }
625    }
626}
627impl Default for ReturnOutboundTransferTreasuryOutboundTransferReturnedDetails {
628    fn default() -> Self {
629        Self::new()
630    }
631}
632/// Reason for the return.
633#[derive(Clone, Eq, PartialEq)]
634#[non_exhaustive]
635pub enum ReturnOutboundTransferTreasuryOutboundTransferReturnedDetailsCode {
636    AccountClosed,
637    AccountFrozen,
638    BankAccountRestricted,
639    BankOwnershipChanged,
640    Declined,
641    IncorrectAccountHolderName,
642    InvalidAccountNumber,
643    InvalidCurrency,
644    NoAccount,
645    Other,
646    /// An unrecognized value from Stripe. Should not be used as a request parameter.
647    Unknown(String),
648}
649impl ReturnOutboundTransferTreasuryOutboundTransferReturnedDetailsCode {
650    pub fn as_str(&self) -> &str {
651        use ReturnOutboundTransferTreasuryOutboundTransferReturnedDetailsCode::*;
652        match self {
653            AccountClosed => "account_closed",
654            AccountFrozen => "account_frozen",
655            BankAccountRestricted => "bank_account_restricted",
656            BankOwnershipChanged => "bank_ownership_changed",
657            Declined => "declined",
658            IncorrectAccountHolderName => "incorrect_account_holder_name",
659            InvalidAccountNumber => "invalid_account_number",
660            InvalidCurrency => "invalid_currency",
661            NoAccount => "no_account",
662            Other => "other",
663            Unknown(v) => v,
664        }
665    }
666}
667
668impl std::str::FromStr for ReturnOutboundTransferTreasuryOutboundTransferReturnedDetailsCode {
669    type Err = std::convert::Infallible;
670    fn from_str(s: &str) -> Result<Self, Self::Err> {
671        use ReturnOutboundTransferTreasuryOutboundTransferReturnedDetailsCode::*;
672        match s {
673            "account_closed" => Ok(AccountClosed),
674            "account_frozen" => Ok(AccountFrozen),
675            "bank_account_restricted" => Ok(BankAccountRestricted),
676            "bank_ownership_changed" => Ok(BankOwnershipChanged),
677            "declined" => Ok(Declined),
678            "incorrect_account_holder_name" => Ok(IncorrectAccountHolderName),
679            "invalid_account_number" => Ok(InvalidAccountNumber),
680            "invalid_currency" => Ok(InvalidCurrency),
681            "no_account" => Ok(NoAccount),
682            "other" => Ok(Other),
683            v => {
684                tracing::warn!(
685                    "Unknown value '{}' for enum '{}'",
686                    v,
687                    "ReturnOutboundTransferTreasuryOutboundTransferReturnedDetailsCode"
688                );
689                Ok(Unknown(v.to_owned()))
690            }
691        }
692    }
693}
694impl std::fmt::Display for ReturnOutboundTransferTreasuryOutboundTransferReturnedDetailsCode {
695    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
696        f.write_str(self.as_str())
697    }
698}
699
700#[cfg(not(feature = "redact-generated-debug"))]
701impl std::fmt::Debug for ReturnOutboundTransferTreasuryOutboundTransferReturnedDetailsCode {
702    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
703        f.write_str(self.as_str())
704    }
705}
706#[cfg(feature = "redact-generated-debug")]
707impl std::fmt::Debug for ReturnOutboundTransferTreasuryOutboundTransferReturnedDetailsCode {
708    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
709        f.debug_struct(stringify!(
710            ReturnOutboundTransferTreasuryOutboundTransferReturnedDetailsCode
711        ))
712        .finish_non_exhaustive()
713    }
714}
715impl serde::Serialize for ReturnOutboundTransferTreasuryOutboundTransferReturnedDetailsCode {
716    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
717    where
718        S: serde::Serializer,
719    {
720        serializer.serialize_str(self.as_str())
721    }
722}
723#[cfg(feature = "deserialize")]
724impl<'de> serde::Deserialize<'de>
725    for ReturnOutboundTransferTreasuryOutboundTransferReturnedDetailsCode
726{
727    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
728        use std::str::FromStr;
729        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
730        Ok(Self::from_str(&s).expect("infallible"))
731    }
732}
733/// Transitions a test mode created OutboundTransfer to the `returned` status.
734/// The OutboundTransfer must already be in the `processing` state.
735#[derive(Clone)]
736#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
737#[derive(serde::Serialize)]
738pub struct ReturnOutboundTransferTreasuryOutboundTransfer {
739    inner: ReturnOutboundTransferTreasuryOutboundTransferBuilder,
740    outbound_transfer: String,
741}
742#[cfg(feature = "redact-generated-debug")]
743impl std::fmt::Debug for ReturnOutboundTransferTreasuryOutboundTransfer {
744    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
745        f.debug_struct("ReturnOutboundTransferTreasuryOutboundTransfer").finish_non_exhaustive()
746    }
747}
748impl ReturnOutboundTransferTreasuryOutboundTransfer {
749    /// Construct a new `ReturnOutboundTransferTreasuryOutboundTransfer`.
750    pub fn new(outbound_transfer: impl Into<String>) -> Self {
751        Self {
752            outbound_transfer: outbound_transfer.into(),
753            inner: ReturnOutboundTransferTreasuryOutboundTransferBuilder::new(),
754        }
755    }
756    /// Specifies which fields in the response should be expanded.
757    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
758        self.inner.expand = Some(expand.into());
759        self
760    }
761    /// Details about a returned OutboundTransfer.
762    pub fn returned_details(
763        mut self,
764        returned_details: impl Into<ReturnOutboundTransferTreasuryOutboundTransferReturnedDetails>,
765    ) -> Self {
766        self.inner.returned_details = Some(returned_details.into());
767        self
768    }
769}
770impl ReturnOutboundTransferTreasuryOutboundTransfer {
771    /// Send the request and return the deserialized response.
772    pub async fn send<C: StripeClient>(
773        &self,
774        client: &C,
775    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
776        self.customize().send(client).await
777    }
778
779    /// Send the request and return the deserialized response, blocking until completion.
780    pub fn send_blocking<C: StripeBlockingClient>(
781        &self,
782        client: &C,
783    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
784        self.customize().send_blocking(client)
785    }
786}
787
788impl StripeRequest for ReturnOutboundTransferTreasuryOutboundTransfer {
789    type Output = stripe_treasury::TreasuryOutboundTransfer;
790
791    fn build(&self) -> RequestBuilder {
792        let outbound_transfer = &self.outbound_transfer;
793        RequestBuilder::new(
794            StripeMethod::Post,
795            format!("/test_helpers/treasury/outbound_transfers/{outbound_transfer}/return"),
796        )
797        .form(&self.inner)
798    }
799}
800#[derive(Clone)]
801#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
802#[derive(serde::Serialize)]
803struct CreateTreasuryOutboundTransferBuilder {
804    amount: i64,
805    currency: stripe_types::Currency,
806    #[serde(skip_serializing_if = "Option::is_none")]
807    description: Option<String>,
808    #[serde(skip_serializing_if = "Option::is_none")]
809    destination_payment_method: Option<String>,
810    #[serde(skip_serializing_if = "Option::is_none")]
811    destination_payment_method_data:
812        Option<CreateTreasuryOutboundTransferDestinationPaymentMethodData>,
813    #[serde(skip_serializing_if = "Option::is_none")]
814    destination_payment_method_options:
815        Option<CreateTreasuryOutboundTransferDestinationPaymentMethodOptions>,
816    #[serde(skip_serializing_if = "Option::is_none")]
817    expand: Option<Vec<String>>,
818    financial_account: String,
819    #[serde(skip_serializing_if = "Option::is_none")]
820    metadata: Option<std::collections::HashMap<String, String>>,
821    #[serde(skip_serializing_if = "Option::is_none")]
822    statement_descriptor: Option<String>,
823}
824#[cfg(feature = "redact-generated-debug")]
825impl std::fmt::Debug for CreateTreasuryOutboundTransferBuilder {
826    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
827        f.debug_struct("CreateTreasuryOutboundTransferBuilder").finish_non_exhaustive()
828    }
829}
830impl CreateTreasuryOutboundTransferBuilder {
831    fn new(
832        amount: impl Into<i64>,
833        currency: impl Into<stripe_types::Currency>,
834        financial_account: impl Into<String>,
835    ) -> Self {
836        Self {
837            amount: amount.into(),
838            currency: currency.into(),
839            description: None,
840            destination_payment_method: None,
841            destination_payment_method_data: None,
842            destination_payment_method_options: None,
843            expand: None,
844            financial_account: financial_account.into(),
845            metadata: None,
846            statement_descriptor: None,
847        }
848    }
849}
850/// Hash used to generate the PaymentMethod to be used for this OutboundTransfer.
851/// Exclusive with `destination_payment_method`.
852#[derive(Clone, Eq, PartialEq)]
853#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
854#[derive(serde::Serialize)]
855pub struct CreateTreasuryOutboundTransferDestinationPaymentMethodData {
856    /// Required if type is set to `financial_account`. The FinancialAccount ID to send funds to.
857    #[serde(skip_serializing_if = "Option::is_none")]
858    pub financial_account: Option<String>,
859    /// The type of the destination.
860    #[serde(rename = "type")]
861    pub type_: CreateTreasuryOutboundTransferDestinationPaymentMethodDataType,
862}
863#[cfg(feature = "redact-generated-debug")]
864impl std::fmt::Debug for CreateTreasuryOutboundTransferDestinationPaymentMethodData {
865    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
866        f.debug_struct("CreateTreasuryOutboundTransferDestinationPaymentMethodData")
867            .finish_non_exhaustive()
868    }
869}
870impl CreateTreasuryOutboundTransferDestinationPaymentMethodData {
871    pub fn new(
872        type_: impl Into<CreateTreasuryOutboundTransferDestinationPaymentMethodDataType>,
873    ) -> Self {
874        Self { financial_account: None, type_: type_.into() }
875    }
876}
877/// The type of the destination.
878#[derive(Clone, Eq, PartialEq)]
879#[non_exhaustive]
880pub enum CreateTreasuryOutboundTransferDestinationPaymentMethodDataType {
881    FinancialAccount,
882    /// An unrecognized value from Stripe. Should not be used as a request parameter.
883    Unknown(String),
884}
885impl CreateTreasuryOutboundTransferDestinationPaymentMethodDataType {
886    pub fn as_str(&self) -> &str {
887        use CreateTreasuryOutboundTransferDestinationPaymentMethodDataType::*;
888        match self {
889            FinancialAccount => "financial_account",
890            Unknown(v) => v,
891        }
892    }
893}
894
895impl std::str::FromStr for CreateTreasuryOutboundTransferDestinationPaymentMethodDataType {
896    type Err = std::convert::Infallible;
897    fn from_str(s: &str) -> Result<Self, Self::Err> {
898        use CreateTreasuryOutboundTransferDestinationPaymentMethodDataType::*;
899        match s {
900            "financial_account" => Ok(FinancialAccount),
901            v => {
902                tracing::warn!(
903                    "Unknown value '{}' for enum '{}'",
904                    v,
905                    "CreateTreasuryOutboundTransferDestinationPaymentMethodDataType"
906                );
907                Ok(Unknown(v.to_owned()))
908            }
909        }
910    }
911}
912impl std::fmt::Display for CreateTreasuryOutboundTransferDestinationPaymentMethodDataType {
913    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
914        f.write_str(self.as_str())
915    }
916}
917
918#[cfg(not(feature = "redact-generated-debug"))]
919impl std::fmt::Debug for CreateTreasuryOutboundTransferDestinationPaymentMethodDataType {
920    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
921        f.write_str(self.as_str())
922    }
923}
924#[cfg(feature = "redact-generated-debug")]
925impl std::fmt::Debug for CreateTreasuryOutboundTransferDestinationPaymentMethodDataType {
926    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
927        f.debug_struct(stringify!(CreateTreasuryOutboundTransferDestinationPaymentMethodDataType))
928            .finish_non_exhaustive()
929    }
930}
931impl serde::Serialize for CreateTreasuryOutboundTransferDestinationPaymentMethodDataType {
932    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
933    where
934        S: serde::Serializer,
935    {
936        serializer.serialize_str(self.as_str())
937    }
938}
939#[cfg(feature = "deserialize")]
940impl<'de> serde::Deserialize<'de>
941    for CreateTreasuryOutboundTransferDestinationPaymentMethodDataType
942{
943    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
944        use std::str::FromStr;
945        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
946        Ok(Self::from_str(&s).expect("infallible"))
947    }
948}
949/// Hash describing payment method configuration details.
950#[derive(Clone, Eq, PartialEq)]
951#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
952#[derive(serde::Serialize)]
953pub struct CreateTreasuryOutboundTransferDestinationPaymentMethodOptions {
954    /// Optional fields for `us_bank_account`.
955    #[serde(skip_serializing_if = "Option::is_none")]
956    pub us_bank_account:
957        Option<CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccount>,
958}
959#[cfg(feature = "redact-generated-debug")]
960impl std::fmt::Debug for CreateTreasuryOutboundTransferDestinationPaymentMethodOptions {
961    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
962        f.debug_struct("CreateTreasuryOutboundTransferDestinationPaymentMethodOptions")
963            .finish_non_exhaustive()
964    }
965}
966impl CreateTreasuryOutboundTransferDestinationPaymentMethodOptions {
967    pub fn new() -> Self {
968        Self { us_bank_account: None }
969    }
970}
971impl Default for CreateTreasuryOutboundTransferDestinationPaymentMethodOptions {
972    fn default() -> Self {
973        Self::new()
974    }
975}
976/// Optional fields for `us_bank_account`.
977#[derive(Clone, Eq, PartialEq)]
978#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
979#[derive(serde::Serialize)]
980pub struct CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccount {
981    /// Specifies the network rails to be used.
982    /// If not set, will default to the PaymentMethod's preferred network.
983    /// See the [docs](https://docs.stripe.com/treasury/money-movement/timelines) to learn more about money movement timelines for each network type.
984    #[serde(skip_serializing_if = "Option::is_none")]
985    pub network:
986        Option<CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork>,
987}
988#[cfg(feature = "redact-generated-debug")]
989impl std::fmt::Debug
990    for CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccount
991{
992    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
993        f.debug_struct("CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccount")
994            .finish_non_exhaustive()
995    }
996}
997impl CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccount {
998    pub fn new() -> Self {
999        Self { network: None }
1000    }
1001}
1002impl Default for CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccount {
1003    fn default() -> Self {
1004        Self::new()
1005    }
1006}
1007/// Specifies the network rails to be used.
1008/// If not set, will default to the PaymentMethod's preferred network.
1009/// See the [docs](https://docs.stripe.com/treasury/money-movement/timelines) to learn more about money movement timelines for each network type.
1010#[derive(Clone, Eq, PartialEq)]
1011#[non_exhaustive]
1012pub enum CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork {
1013    Ach,
1014    UsDomesticWire,
1015    /// An unrecognized value from Stripe. Should not be used as a request parameter.
1016    Unknown(String),
1017}
1018impl CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork {
1019    pub fn as_str(&self) -> &str {
1020        use CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork::*;
1021        match self {
1022            Ach => "ach",
1023            UsDomesticWire => "us_domestic_wire",
1024            Unknown(v) => v,
1025        }
1026    }
1027}
1028
1029impl std::str::FromStr
1030    for CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork
1031{
1032    type Err = std::convert::Infallible;
1033    fn from_str(s: &str) -> Result<Self, Self::Err> {
1034        use CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork::*;
1035        match s {
1036            "ach" => Ok(Ach),
1037            "us_domestic_wire" => Ok(UsDomesticWire),
1038            v => {
1039                tracing::warn!(
1040                    "Unknown value '{}' for enum '{}'",
1041                    v,
1042                    "CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork"
1043                );
1044                Ok(Unknown(v.to_owned()))
1045            }
1046        }
1047    }
1048}
1049impl std::fmt::Display
1050    for CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork
1051{
1052    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1053        f.write_str(self.as_str())
1054    }
1055}
1056
1057#[cfg(not(feature = "redact-generated-debug"))]
1058impl std::fmt::Debug
1059    for CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork
1060{
1061    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1062        f.write_str(self.as_str())
1063    }
1064}
1065#[cfg(feature = "redact-generated-debug")]
1066impl std::fmt::Debug
1067    for CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork
1068{
1069    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1070        f.debug_struct(stringify!(
1071            CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork
1072        ))
1073        .finish_non_exhaustive()
1074    }
1075}
1076impl serde::Serialize
1077    for CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork
1078{
1079    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1080    where
1081        S: serde::Serializer,
1082    {
1083        serializer.serialize_str(self.as_str())
1084    }
1085}
1086#[cfg(feature = "deserialize")]
1087impl<'de> serde::Deserialize<'de>
1088    for CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork
1089{
1090    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1091        use std::str::FromStr;
1092        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1093        Ok(Self::from_str(&s).expect("infallible"))
1094    }
1095}
1096/// Creates an OutboundTransfer.
1097#[derive(Clone)]
1098#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
1099#[derive(serde::Serialize)]
1100pub struct CreateTreasuryOutboundTransfer {
1101    inner: CreateTreasuryOutboundTransferBuilder,
1102}
1103#[cfg(feature = "redact-generated-debug")]
1104impl std::fmt::Debug for CreateTreasuryOutboundTransfer {
1105    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1106        f.debug_struct("CreateTreasuryOutboundTransfer").finish_non_exhaustive()
1107    }
1108}
1109impl CreateTreasuryOutboundTransfer {
1110    /// Construct a new `CreateTreasuryOutboundTransfer`.
1111    pub fn new(
1112        amount: impl Into<i64>,
1113        currency: impl Into<stripe_types::Currency>,
1114        financial_account: impl Into<String>,
1115    ) -> Self {
1116        Self {
1117            inner: CreateTreasuryOutboundTransferBuilder::new(
1118                amount.into(),
1119                currency.into(),
1120                financial_account.into(),
1121            ),
1122        }
1123    }
1124    /// An arbitrary string attached to the object. Often useful for displaying to users.
1125    pub fn description(mut self, description: impl Into<String>) -> Self {
1126        self.inner.description = Some(description.into());
1127        self
1128    }
1129    /// The PaymentMethod to use as the payment instrument for the OutboundTransfer.
1130    pub fn destination_payment_method(
1131        mut self,
1132        destination_payment_method: impl Into<String>,
1133    ) -> Self {
1134        self.inner.destination_payment_method = Some(destination_payment_method.into());
1135        self
1136    }
1137    /// Hash used to generate the PaymentMethod to be used for this OutboundTransfer.
1138    /// Exclusive with `destination_payment_method`.
1139    pub fn destination_payment_method_data(
1140        mut self,
1141        destination_payment_method_data: impl Into<
1142            CreateTreasuryOutboundTransferDestinationPaymentMethodData,
1143        >,
1144    ) -> Self {
1145        self.inner.destination_payment_method_data = Some(destination_payment_method_data.into());
1146        self
1147    }
1148    /// Hash describing payment method configuration details.
1149    pub fn destination_payment_method_options(
1150        mut self,
1151        destination_payment_method_options: impl Into<
1152            CreateTreasuryOutboundTransferDestinationPaymentMethodOptions,
1153        >,
1154    ) -> Self {
1155        self.inner.destination_payment_method_options =
1156            Some(destination_payment_method_options.into());
1157        self
1158    }
1159    /// Specifies which fields in the response should be expanded.
1160    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
1161        self.inner.expand = Some(expand.into());
1162        self
1163    }
1164    /// Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object.
1165    /// This can be useful for storing additional information about the object in a structured format.
1166    /// Individual keys can be unset by posting an empty value to them.
1167    /// All keys can be unset by posting an empty value to `metadata`.
1168    pub fn metadata(
1169        mut self,
1170        metadata: impl Into<std::collections::HashMap<String, String>>,
1171    ) -> Self {
1172        self.inner.metadata = Some(metadata.into());
1173        self
1174    }
1175    /// Statement descriptor to be shown on the receiving end of an OutboundTransfer.
1176    /// Maximum 10 characters for `ach` transfers or 140 characters for `us_domestic_wire` transfers.
1177    /// The default value is "transfer".
1178    /// Can only include -#.$&*, spaces, and alphanumeric characters.
1179    pub fn statement_descriptor(mut self, statement_descriptor: impl Into<String>) -> Self {
1180        self.inner.statement_descriptor = Some(statement_descriptor.into());
1181        self
1182    }
1183}
1184impl CreateTreasuryOutboundTransfer {
1185    /// Send the request and return the deserialized response.
1186    pub async fn send<C: StripeClient>(
1187        &self,
1188        client: &C,
1189    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
1190        self.customize().send(client).await
1191    }
1192
1193    /// Send the request and return the deserialized response, blocking until completion.
1194    pub fn send_blocking<C: StripeBlockingClient>(
1195        &self,
1196        client: &C,
1197    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
1198        self.customize().send_blocking(client)
1199    }
1200}
1201
1202impl StripeRequest for CreateTreasuryOutboundTransfer {
1203    type Output = stripe_treasury::TreasuryOutboundTransfer;
1204
1205    fn build(&self) -> RequestBuilder {
1206        RequestBuilder::new(StripeMethod::Post, "/treasury/outbound_transfers").form(&self.inner)
1207    }
1208}
1209#[derive(Clone, Eq, PartialEq)]
1210#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
1211#[derive(serde::Serialize)]
1212struct CancelTreasuryOutboundTransferBuilder {
1213    #[serde(skip_serializing_if = "Option::is_none")]
1214    expand: Option<Vec<String>>,
1215}
1216#[cfg(feature = "redact-generated-debug")]
1217impl std::fmt::Debug for CancelTreasuryOutboundTransferBuilder {
1218    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1219        f.debug_struct("CancelTreasuryOutboundTransferBuilder").finish_non_exhaustive()
1220    }
1221}
1222impl CancelTreasuryOutboundTransferBuilder {
1223    fn new() -> Self {
1224        Self { expand: None }
1225    }
1226}
1227/// An OutboundTransfer can be canceled if the funds have not yet been paid out.
1228#[derive(Clone)]
1229#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
1230#[derive(serde::Serialize)]
1231pub struct CancelTreasuryOutboundTransfer {
1232    inner: CancelTreasuryOutboundTransferBuilder,
1233    outbound_transfer: stripe_treasury::TreasuryOutboundTransferId,
1234}
1235#[cfg(feature = "redact-generated-debug")]
1236impl std::fmt::Debug for CancelTreasuryOutboundTransfer {
1237    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1238        f.debug_struct("CancelTreasuryOutboundTransfer").finish_non_exhaustive()
1239    }
1240}
1241impl CancelTreasuryOutboundTransfer {
1242    /// Construct a new `CancelTreasuryOutboundTransfer`.
1243    pub fn new(outbound_transfer: impl Into<stripe_treasury::TreasuryOutboundTransferId>) -> Self {
1244        Self {
1245            outbound_transfer: outbound_transfer.into(),
1246            inner: CancelTreasuryOutboundTransferBuilder::new(),
1247        }
1248    }
1249    /// Specifies which fields in the response should be expanded.
1250    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
1251        self.inner.expand = Some(expand.into());
1252        self
1253    }
1254}
1255impl CancelTreasuryOutboundTransfer {
1256    /// Send the request and return the deserialized response.
1257    pub async fn send<C: StripeClient>(
1258        &self,
1259        client: &C,
1260    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
1261        self.customize().send(client).await
1262    }
1263
1264    /// Send the request and return the deserialized response, blocking until completion.
1265    pub fn send_blocking<C: StripeBlockingClient>(
1266        &self,
1267        client: &C,
1268    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
1269        self.customize().send_blocking(client)
1270    }
1271}
1272
1273impl StripeRequest for CancelTreasuryOutboundTransfer {
1274    type Output = stripe_treasury::TreasuryOutboundTransfer;
1275
1276    fn build(&self) -> RequestBuilder {
1277        let outbound_transfer = &self.outbound_transfer;
1278        RequestBuilder::new(
1279            StripeMethod::Post,
1280            format!("/treasury/outbound_transfers/{outbound_transfer}/cancel"),
1281        )
1282        .form(&self.inner)
1283    }
1284}