Skip to main content

stripe_connect/external_account/
requests.rs

1use stripe_client_core::{
2    RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5/// Delete a specified external account for a given account.
6#[derive(Clone)]
7#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
8#[derive(serde::Serialize)]
9pub struct DeleteExternalAccount {
10    account: stripe_shared::AccountId,
11    id: String,
12}
13#[cfg(feature = "redact-generated-debug")]
14impl std::fmt::Debug for DeleteExternalAccount {
15    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
16        f.debug_struct("DeleteExternalAccount").finish_non_exhaustive()
17    }
18}
19impl DeleteExternalAccount {
20    /// Construct a new `DeleteExternalAccount`.
21    pub fn new(account: impl Into<stripe_shared::AccountId>, id: impl Into<String>) -> Self {
22        Self { account: account.into(), id: id.into() }
23    }
24}
25impl DeleteExternalAccount {
26    /// Send the request and return the deserialized response.
27    pub async fn send<C: StripeClient>(
28        &self,
29        client: &C,
30    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
31        self.customize().send(client).await
32    }
33
34    /// Send the request and return the deserialized response, blocking until completion.
35    pub fn send_blocking<C: StripeBlockingClient>(
36        &self,
37        client: &C,
38    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
39        self.customize().send_blocking(client)
40    }
41}
42
43impl StripeRequest for DeleteExternalAccount {
44    type Output = stripe_shared::DeletedExternalAccount;
45
46    fn build(&self) -> RequestBuilder {
47        let account = &self.account;
48        let id = &self.id;
49        RequestBuilder::new(
50            StripeMethod::Delete,
51            format!("/accounts/{account}/external_accounts/{id}"),
52        )
53    }
54}
55#[derive(Clone, Eq, PartialEq)]
56#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
57#[derive(serde::Serialize)]
58struct ListAccountExternalAccountBuilder {
59    #[serde(skip_serializing_if = "Option::is_none")]
60    ending_before: Option<String>,
61    #[serde(skip_serializing_if = "Option::is_none")]
62    expand: Option<Vec<String>>,
63    #[serde(skip_serializing_if = "Option::is_none")]
64    limit: Option<i64>,
65    #[serde(skip_serializing_if = "Option::is_none")]
66    object: Option<ListAccountExternalAccountObject>,
67    #[serde(skip_serializing_if = "Option::is_none")]
68    starting_after: Option<String>,
69}
70#[cfg(feature = "redact-generated-debug")]
71impl std::fmt::Debug for ListAccountExternalAccountBuilder {
72    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
73        f.debug_struct("ListAccountExternalAccountBuilder").finish_non_exhaustive()
74    }
75}
76impl ListAccountExternalAccountBuilder {
77    fn new() -> Self {
78        Self { ending_before: None, expand: None, limit: None, object: None, starting_after: None }
79    }
80}
81/// Filter external accounts according to a particular object type.
82#[derive(Clone, Eq, PartialEq)]
83#[non_exhaustive]
84pub enum ListAccountExternalAccountObject {
85    BankAccount,
86    Card,
87    /// An unrecognized value from Stripe. Should not be used as a request parameter.
88    Unknown(String),
89}
90impl ListAccountExternalAccountObject {
91    pub fn as_str(&self) -> &str {
92        use ListAccountExternalAccountObject::*;
93        match self {
94            BankAccount => "bank_account",
95            Card => "card",
96            Unknown(v) => v,
97        }
98    }
99}
100
101impl std::str::FromStr for ListAccountExternalAccountObject {
102    type Err = std::convert::Infallible;
103    fn from_str(s: &str) -> Result<Self, Self::Err> {
104        use ListAccountExternalAccountObject::*;
105        match s {
106            "bank_account" => Ok(BankAccount),
107            "card" => Ok(Card),
108            v => {
109                tracing::warn!(
110                    "Unknown value '{}' for enum '{}'",
111                    v,
112                    "ListAccountExternalAccountObject"
113                );
114                Ok(Unknown(v.to_owned()))
115            }
116        }
117    }
118}
119impl std::fmt::Display for ListAccountExternalAccountObject {
120    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
121        f.write_str(self.as_str())
122    }
123}
124
125#[cfg(not(feature = "redact-generated-debug"))]
126impl std::fmt::Debug for ListAccountExternalAccountObject {
127    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
128        f.write_str(self.as_str())
129    }
130}
131#[cfg(feature = "redact-generated-debug")]
132impl std::fmt::Debug for ListAccountExternalAccountObject {
133    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
134        f.debug_struct(stringify!(ListAccountExternalAccountObject)).finish_non_exhaustive()
135    }
136}
137impl serde::Serialize for ListAccountExternalAccountObject {
138    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
139    where
140        S: serde::Serializer,
141    {
142        serializer.serialize_str(self.as_str())
143    }
144}
145#[cfg(feature = "deserialize")]
146impl<'de> serde::Deserialize<'de> for ListAccountExternalAccountObject {
147    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
148        use std::str::FromStr;
149        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
150        Ok(Self::from_str(&s).expect("infallible"))
151    }
152}
153/// List external accounts for an account.
154#[derive(Clone)]
155#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
156#[derive(serde::Serialize)]
157pub struct ListAccountExternalAccount {
158    inner: ListAccountExternalAccountBuilder,
159    account: stripe_shared::AccountId,
160}
161#[cfg(feature = "redact-generated-debug")]
162impl std::fmt::Debug for ListAccountExternalAccount {
163    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
164        f.debug_struct("ListAccountExternalAccount").finish_non_exhaustive()
165    }
166}
167impl ListAccountExternalAccount {
168    /// Construct a new `ListAccountExternalAccount`.
169    pub fn new(account: impl Into<stripe_shared::AccountId>) -> Self {
170        Self { account: account.into(), inner: ListAccountExternalAccountBuilder::new() }
171    }
172    /// A cursor for use in pagination.
173    /// `ending_before` is an object ID that defines your place in the list.
174    /// 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.
175    pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
176        self.inner.ending_before = Some(ending_before.into());
177        self
178    }
179    /// Specifies which fields in the response should be expanded.
180    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
181        self.inner.expand = Some(expand.into());
182        self
183    }
184    /// A limit on the number of objects to be returned.
185    /// Limit can range between 1 and 100, and the default is 10.
186    pub fn limit(mut self, limit: impl Into<i64>) -> Self {
187        self.inner.limit = Some(limit.into());
188        self
189    }
190    /// Filter external accounts according to a particular object type.
191    pub fn object(mut self, object: impl Into<ListAccountExternalAccountObject>) -> Self {
192        self.inner.object = Some(object.into());
193        self
194    }
195    /// A cursor for use in pagination.
196    /// `starting_after` is an object ID that defines your place in the list.
197    /// 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.
198    pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
199        self.inner.starting_after = Some(starting_after.into());
200        self
201    }
202}
203impl ListAccountExternalAccount {
204    /// Send the request and return the deserialized response.
205    pub async fn send<C: StripeClient>(
206        &self,
207        client: &C,
208    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
209        self.customize().send(client).await
210    }
211
212    /// Send the request and return the deserialized response, blocking until completion.
213    pub fn send_blocking<C: StripeBlockingClient>(
214        &self,
215        client: &C,
216    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
217        self.customize().send_blocking(client)
218    }
219
220    pub fn paginate(
221        &self,
222    ) -> stripe_client_core::ListPaginator<stripe_types::List<stripe_shared::ExternalAccount>> {
223        let account = &self.account;
224
225        stripe_client_core::ListPaginator::new_list(
226            format!("/accounts/{account}/external_accounts"),
227            &self.inner,
228        )
229    }
230}
231
232impl StripeRequest for ListAccountExternalAccount {
233    type Output = stripe_types::List<stripe_shared::ExternalAccount>;
234
235    fn build(&self) -> RequestBuilder {
236        let account = &self.account;
237        RequestBuilder::new(StripeMethod::Get, format!("/accounts/{account}/external_accounts"))
238            .query(&self.inner)
239    }
240}
241#[derive(Clone, Eq, PartialEq)]
242#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
243#[derive(serde::Serialize)]
244struct RetrieveExternalAccountBuilder {
245    #[serde(skip_serializing_if = "Option::is_none")]
246    expand: Option<Vec<String>>,
247}
248#[cfg(feature = "redact-generated-debug")]
249impl std::fmt::Debug for RetrieveExternalAccountBuilder {
250    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
251        f.debug_struct("RetrieveExternalAccountBuilder").finish_non_exhaustive()
252    }
253}
254impl RetrieveExternalAccountBuilder {
255    fn new() -> Self {
256        Self { expand: None }
257    }
258}
259/// Retrieve a specified external account for a given account.
260#[derive(Clone)]
261#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
262#[derive(serde::Serialize)]
263pub struct RetrieveExternalAccount {
264    inner: RetrieveExternalAccountBuilder,
265    account: stripe_shared::AccountId,
266    id: String,
267}
268#[cfg(feature = "redact-generated-debug")]
269impl std::fmt::Debug for RetrieveExternalAccount {
270    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
271        f.debug_struct("RetrieveExternalAccount").finish_non_exhaustive()
272    }
273}
274impl RetrieveExternalAccount {
275    /// Construct a new `RetrieveExternalAccount`.
276    pub fn new(account: impl Into<stripe_shared::AccountId>, id: impl Into<String>) -> Self {
277        Self {
278            account: account.into(),
279            id: id.into(),
280            inner: RetrieveExternalAccountBuilder::new(),
281        }
282    }
283    /// Specifies which fields in the response should be expanded.
284    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
285        self.inner.expand = Some(expand.into());
286        self
287    }
288}
289impl RetrieveExternalAccount {
290    /// Send the request and return the deserialized response.
291    pub async fn send<C: StripeClient>(
292        &self,
293        client: &C,
294    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
295        self.customize().send(client).await
296    }
297
298    /// Send the request and return the deserialized response, blocking until completion.
299    pub fn send_blocking<C: StripeBlockingClient>(
300        &self,
301        client: &C,
302    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
303        self.customize().send_blocking(client)
304    }
305}
306
307impl StripeRequest for RetrieveExternalAccount {
308    type Output = stripe_shared::ExternalAccount;
309
310    fn build(&self) -> RequestBuilder {
311        let account = &self.account;
312        let id = &self.id;
313        RequestBuilder::new(
314            StripeMethod::Get,
315            format!("/accounts/{account}/external_accounts/{id}"),
316        )
317        .query(&self.inner)
318    }
319}
320#[derive(Clone)]
321#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
322#[derive(serde::Serialize)]
323struct CreateAccountExternalAccountBuilder {
324    #[serde(skip_serializing_if = "Option::is_none")]
325    default_for_currency: Option<bool>,
326    #[serde(skip_serializing_if = "Option::is_none")]
327    expand: Option<Vec<String>>,
328    external_account: String,
329    #[serde(skip_serializing_if = "Option::is_none")]
330    metadata: Option<std::collections::HashMap<String, String>>,
331}
332#[cfg(feature = "redact-generated-debug")]
333impl std::fmt::Debug for CreateAccountExternalAccountBuilder {
334    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
335        f.debug_struct("CreateAccountExternalAccountBuilder").finish_non_exhaustive()
336    }
337}
338impl CreateAccountExternalAccountBuilder {
339    fn new(external_account: impl Into<String>) -> Self {
340        Self {
341            default_for_currency: None,
342            expand: None,
343            external_account: external_account.into(),
344            metadata: None,
345        }
346    }
347}
348/// Create an external account for a given account.
349#[derive(Clone)]
350#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
351#[derive(serde::Serialize)]
352pub struct CreateAccountExternalAccount {
353    inner: CreateAccountExternalAccountBuilder,
354    account: stripe_shared::AccountId,
355}
356#[cfg(feature = "redact-generated-debug")]
357impl std::fmt::Debug for CreateAccountExternalAccount {
358    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
359        f.debug_struct("CreateAccountExternalAccount").finish_non_exhaustive()
360    }
361}
362impl CreateAccountExternalAccount {
363    /// Construct a new `CreateAccountExternalAccount`.
364    pub fn new(
365        account: impl Into<stripe_shared::AccountId>,
366        external_account: impl Into<String>,
367    ) -> Self {
368        Self {
369            account: account.into(),
370            inner: CreateAccountExternalAccountBuilder::new(external_account.into()),
371        }
372    }
373    /// When set to true, or if this is the first external account added in this currency, this account becomes the default external account for its currency.
374    pub fn default_for_currency(mut self, default_for_currency: impl Into<bool>) -> Self {
375        self.inner.default_for_currency = Some(default_for_currency.into());
376        self
377    }
378    /// Specifies which fields in the response should be expanded.
379    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
380        self.inner.expand = Some(expand.into());
381        self
382    }
383    /// Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object.
384    /// This can be useful for storing additional information about the object in a structured format.
385    /// Individual keys can be unset by posting an empty value to them.
386    /// All keys can be unset by posting an empty value to `metadata`.
387    pub fn metadata(
388        mut self,
389        metadata: impl Into<std::collections::HashMap<String, String>>,
390    ) -> Self {
391        self.inner.metadata = Some(metadata.into());
392        self
393    }
394}
395impl CreateAccountExternalAccount {
396    /// Send the request and return the deserialized response.
397    pub async fn send<C: StripeClient>(
398        &self,
399        client: &C,
400    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
401        self.customize().send(client).await
402    }
403
404    /// Send the request and return the deserialized response, blocking until completion.
405    pub fn send_blocking<C: StripeBlockingClient>(
406        &self,
407        client: &C,
408    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
409        self.customize().send_blocking(client)
410    }
411}
412
413impl StripeRequest for CreateAccountExternalAccount {
414    type Output = stripe_shared::ExternalAccount;
415
416    fn build(&self) -> RequestBuilder {
417        let account = &self.account;
418        RequestBuilder::new(StripeMethod::Post, format!("/accounts/{account}/external_accounts"))
419            .form(&self.inner)
420    }
421}
422#[derive(Clone)]
423#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
424#[derive(serde::Serialize)]
425struct UpdateExternalAccountBuilder {
426    #[serde(skip_serializing_if = "Option::is_none")]
427    account_holder_name: Option<String>,
428    #[serde(skip_serializing_if = "Option::is_none")]
429    account_holder_type: Option<UpdateExternalAccountAccountHolderType>,
430    #[serde(skip_serializing_if = "Option::is_none")]
431    account_type: Option<UpdateExternalAccountAccountType>,
432    #[serde(skip_serializing_if = "Option::is_none")]
433    address_city: Option<String>,
434    #[serde(skip_serializing_if = "Option::is_none")]
435    address_country: Option<String>,
436    #[serde(skip_serializing_if = "Option::is_none")]
437    address_line1: Option<String>,
438    #[serde(skip_serializing_if = "Option::is_none")]
439    address_line2: Option<String>,
440    #[serde(skip_serializing_if = "Option::is_none")]
441    address_state: Option<String>,
442    #[serde(skip_serializing_if = "Option::is_none")]
443    address_zip: Option<String>,
444    #[serde(skip_serializing_if = "Option::is_none")]
445    default_for_currency: Option<bool>,
446    #[serde(skip_serializing_if = "Option::is_none")]
447    documents: Option<UpdateExternalAccountDocuments>,
448    #[serde(skip_serializing_if = "Option::is_none")]
449    exp_month: Option<String>,
450    #[serde(skip_serializing_if = "Option::is_none")]
451    exp_year: Option<String>,
452    #[serde(skip_serializing_if = "Option::is_none")]
453    expand: Option<Vec<String>>,
454    #[serde(skip_serializing_if = "Option::is_none")]
455    metadata: Option<std::collections::HashMap<String, String>>,
456    #[serde(skip_serializing_if = "Option::is_none")]
457    name: Option<String>,
458}
459#[cfg(feature = "redact-generated-debug")]
460impl std::fmt::Debug for UpdateExternalAccountBuilder {
461    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
462        f.debug_struct("UpdateExternalAccountBuilder").finish_non_exhaustive()
463    }
464}
465impl UpdateExternalAccountBuilder {
466    fn new() -> Self {
467        Self {
468            account_holder_name: None,
469            account_holder_type: None,
470            account_type: None,
471            address_city: None,
472            address_country: None,
473            address_line1: None,
474            address_line2: None,
475            address_state: None,
476            address_zip: None,
477            default_for_currency: None,
478            documents: None,
479            exp_month: None,
480            exp_year: None,
481            expand: None,
482            metadata: None,
483            name: None,
484        }
485    }
486}
487/// The type of entity that holds the account. This can be either `individual` or `company`.
488#[derive(Clone, Eq, PartialEq)]
489#[non_exhaustive]
490pub enum UpdateExternalAccountAccountHolderType {
491    Company,
492    Individual,
493    /// An unrecognized value from Stripe. Should not be used as a request parameter.
494    Unknown(String),
495}
496impl UpdateExternalAccountAccountHolderType {
497    pub fn as_str(&self) -> &str {
498        use UpdateExternalAccountAccountHolderType::*;
499        match self {
500            Company => "company",
501            Individual => "individual",
502            Unknown(v) => v,
503        }
504    }
505}
506
507impl std::str::FromStr for UpdateExternalAccountAccountHolderType {
508    type Err = std::convert::Infallible;
509    fn from_str(s: &str) -> Result<Self, Self::Err> {
510        use UpdateExternalAccountAccountHolderType::*;
511        match s {
512            "company" => Ok(Company),
513            "individual" => Ok(Individual),
514            v => {
515                tracing::warn!(
516                    "Unknown value '{}' for enum '{}'",
517                    v,
518                    "UpdateExternalAccountAccountHolderType"
519                );
520                Ok(Unknown(v.to_owned()))
521            }
522        }
523    }
524}
525impl std::fmt::Display for UpdateExternalAccountAccountHolderType {
526    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
527        f.write_str(self.as_str())
528    }
529}
530
531#[cfg(not(feature = "redact-generated-debug"))]
532impl std::fmt::Debug for UpdateExternalAccountAccountHolderType {
533    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
534        f.write_str(self.as_str())
535    }
536}
537#[cfg(feature = "redact-generated-debug")]
538impl std::fmt::Debug for UpdateExternalAccountAccountHolderType {
539    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
540        f.debug_struct(stringify!(UpdateExternalAccountAccountHolderType)).finish_non_exhaustive()
541    }
542}
543impl serde::Serialize for UpdateExternalAccountAccountHolderType {
544    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
545    where
546        S: serde::Serializer,
547    {
548        serializer.serialize_str(self.as_str())
549    }
550}
551#[cfg(feature = "deserialize")]
552impl<'de> serde::Deserialize<'de> for UpdateExternalAccountAccountHolderType {
553    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
554        use std::str::FromStr;
555        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
556        Ok(Self::from_str(&s).expect("infallible"))
557    }
558}
559/// The bank account type.
560/// This can only be `checking` or `savings` in most countries.
561/// In Japan, this can only be `futsu` or `toza`.
562#[derive(Clone, Eq, PartialEq)]
563#[non_exhaustive]
564pub enum UpdateExternalAccountAccountType {
565    Checking,
566    Futsu,
567    Savings,
568    Toza,
569    /// An unrecognized value from Stripe. Should not be used as a request parameter.
570    Unknown(String),
571}
572impl UpdateExternalAccountAccountType {
573    pub fn as_str(&self) -> &str {
574        use UpdateExternalAccountAccountType::*;
575        match self {
576            Checking => "checking",
577            Futsu => "futsu",
578            Savings => "savings",
579            Toza => "toza",
580            Unknown(v) => v,
581        }
582    }
583}
584
585impl std::str::FromStr for UpdateExternalAccountAccountType {
586    type Err = std::convert::Infallible;
587    fn from_str(s: &str) -> Result<Self, Self::Err> {
588        use UpdateExternalAccountAccountType::*;
589        match s {
590            "checking" => Ok(Checking),
591            "futsu" => Ok(Futsu),
592            "savings" => Ok(Savings),
593            "toza" => Ok(Toza),
594            v => {
595                tracing::warn!(
596                    "Unknown value '{}' for enum '{}'",
597                    v,
598                    "UpdateExternalAccountAccountType"
599                );
600                Ok(Unknown(v.to_owned()))
601            }
602        }
603    }
604}
605impl std::fmt::Display for UpdateExternalAccountAccountType {
606    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
607        f.write_str(self.as_str())
608    }
609}
610
611#[cfg(not(feature = "redact-generated-debug"))]
612impl std::fmt::Debug for UpdateExternalAccountAccountType {
613    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
614        f.write_str(self.as_str())
615    }
616}
617#[cfg(feature = "redact-generated-debug")]
618impl std::fmt::Debug for UpdateExternalAccountAccountType {
619    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
620        f.debug_struct(stringify!(UpdateExternalAccountAccountType)).finish_non_exhaustive()
621    }
622}
623impl serde::Serialize for UpdateExternalAccountAccountType {
624    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
625    where
626        S: serde::Serializer,
627    {
628        serializer.serialize_str(self.as_str())
629    }
630}
631#[cfg(feature = "deserialize")]
632impl<'de> serde::Deserialize<'de> for UpdateExternalAccountAccountType {
633    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
634        use std::str::FromStr;
635        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
636        Ok(Self::from_str(&s).expect("infallible"))
637    }
638}
639/// Documents that may be submitted to satisfy various informational requests.
640#[derive(Clone, Eq, PartialEq)]
641#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
642#[derive(serde::Serialize)]
643pub struct UpdateExternalAccountDocuments {
644    /// One or more documents that support the [Bank account ownership verification](https://support.stripe.com/questions/bank-account-ownership-verification) requirement.
645    /// Must be a document associated with the bank account that displays the last 4 digits of the account number, either a statement or a check.
646    #[serde(skip_serializing_if = "Option::is_none")]
647    pub bank_account_ownership_verification:
648        Option<UpdateExternalAccountDocumentsBankAccountOwnershipVerification>,
649}
650#[cfg(feature = "redact-generated-debug")]
651impl std::fmt::Debug for UpdateExternalAccountDocuments {
652    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
653        f.debug_struct("UpdateExternalAccountDocuments").finish_non_exhaustive()
654    }
655}
656impl UpdateExternalAccountDocuments {
657    pub fn new() -> Self {
658        Self { bank_account_ownership_verification: None }
659    }
660}
661impl Default for UpdateExternalAccountDocuments {
662    fn default() -> Self {
663        Self::new()
664    }
665}
666/// One or more documents that support the [Bank account ownership verification](https://support.stripe.com/questions/bank-account-ownership-verification) requirement.
667/// Must be a document associated with the bank account that displays the last 4 digits of the account number, either a statement or a check.
668#[derive(Clone, Eq, PartialEq)]
669#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
670#[derive(serde::Serialize)]
671pub struct UpdateExternalAccountDocumentsBankAccountOwnershipVerification {
672    /// One or more document ids returned by a [file upload](https://api.stripe.com#create_file) with a `purpose` value of `account_requirement`.
673    #[serde(skip_serializing_if = "Option::is_none")]
674    pub files: Option<Vec<String>>,
675}
676#[cfg(feature = "redact-generated-debug")]
677impl std::fmt::Debug for UpdateExternalAccountDocumentsBankAccountOwnershipVerification {
678    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
679        f.debug_struct("UpdateExternalAccountDocumentsBankAccountOwnershipVerification")
680            .finish_non_exhaustive()
681    }
682}
683impl UpdateExternalAccountDocumentsBankAccountOwnershipVerification {
684    pub fn new() -> Self {
685        Self { files: None }
686    }
687}
688impl Default for UpdateExternalAccountDocumentsBankAccountOwnershipVerification {
689    fn default() -> Self {
690        Self::new()
691    }
692}
693/// Updates the metadata, account holder name, account holder type of a bank account belonging to
694/// a connected account and optionally sets it as the default for its currency. Other bank account
695/// details are not editable by design.
696///
697/// You can only update bank accounts when <a href="/api/accounts/object#account_object-controller-requirement_collection">account.controller.requirement_collection</a> is `application`, which includes <a href="/connect/custom-accounts">Custom accounts</a>.
698///
699/// You can re-enable a disabled bank account by performing an update call without providing any
700/// arguments or changes.
701#[derive(Clone)]
702#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
703#[derive(serde::Serialize)]
704pub struct UpdateExternalAccount {
705    inner: UpdateExternalAccountBuilder,
706    account: stripe_shared::AccountId,
707    id: String,
708}
709#[cfg(feature = "redact-generated-debug")]
710impl std::fmt::Debug for UpdateExternalAccount {
711    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
712        f.debug_struct("UpdateExternalAccount").finish_non_exhaustive()
713    }
714}
715impl UpdateExternalAccount {
716    /// Construct a new `UpdateExternalAccount`.
717    pub fn new(account: impl Into<stripe_shared::AccountId>, id: impl Into<String>) -> Self {
718        Self { account: account.into(), id: id.into(), inner: UpdateExternalAccountBuilder::new() }
719    }
720    /// The name of the person or business that owns the bank account.
721    pub fn account_holder_name(mut self, account_holder_name: impl Into<String>) -> Self {
722        self.inner.account_holder_name = Some(account_holder_name.into());
723        self
724    }
725    /// The type of entity that holds the account. This can be either `individual` or `company`.
726    pub fn account_holder_type(
727        mut self,
728        account_holder_type: impl Into<UpdateExternalAccountAccountHolderType>,
729    ) -> Self {
730        self.inner.account_holder_type = Some(account_holder_type.into());
731        self
732    }
733    /// The bank account type.
734    /// This can only be `checking` or `savings` in most countries.
735    /// In Japan, this can only be `futsu` or `toza`.
736    pub fn account_type(
737        mut self,
738        account_type: impl Into<UpdateExternalAccountAccountType>,
739    ) -> Self {
740        self.inner.account_type = Some(account_type.into());
741        self
742    }
743    /// City/District/Suburb/Town/Village.
744    pub fn address_city(mut self, address_city: impl Into<String>) -> Self {
745        self.inner.address_city = Some(address_city.into());
746        self
747    }
748    /// Billing address country, if provided when creating card.
749    pub fn address_country(mut self, address_country: impl Into<String>) -> Self {
750        self.inner.address_country = Some(address_country.into());
751        self
752    }
753    /// Address line 1 (Street address/PO Box/Company name).
754    pub fn address_line1(mut self, address_line1: impl Into<String>) -> Self {
755        self.inner.address_line1 = Some(address_line1.into());
756        self
757    }
758    /// Address line 2 (Apartment/Suite/Unit/Building).
759    pub fn address_line2(mut self, address_line2: impl Into<String>) -> Self {
760        self.inner.address_line2 = Some(address_line2.into());
761        self
762    }
763    /// State/County/Province/Region.
764    pub fn address_state(mut self, address_state: impl Into<String>) -> Self {
765        self.inner.address_state = Some(address_state.into());
766        self
767    }
768    /// ZIP or postal code.
769    pub fn address_zip(mut self, address_zip: impl Into<String>) -> Self {
770        self.inner.address_zip = Some(address_zip.into());
771        self
772    }
773    /// When set to true, this becomes the default external account for its currency.
774    pub fn default_for_currency(mut self, default_for_currency: impl Into<bool>) -> Self {
775        self.inner.default_for_currency = Some(default_for_currency.into());
776        self
777    }
778    /// Documents that may be submitted to satisfy various informational requests.
779    pub fn documents(mut self, documents: impl Into<UpdateExternalAccountDocuments>) -> Self {
780        self.inner.documents = Some(documents.into());
781        self
782    }
783    /// Two digit number representing the card’s expiration month.
784    pub fn exp_month(mut self, exp_month: impl Into<String>) -> Self {
785        self.inner.exp_month = Some(exp_month.into());
786        self
787    }
788    /// Four digit number representing the card’s expiration year.
789    pub fn exp_year(mut self, exp_year: impl Into<String>) -> Self {
790        self.inner.exp_year = Some(exp_year.into());
791        self
792    }
793    /// Specifies which fields in the response should be expanded.
794    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
795        self.inner.expand = Some(expand.into());
796        self
797    }
798    /// Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object.
799    /// This can be useful for storing additional information about the object in a structured format.
800    /// Individual keys can be unset by posting an empty value to them.
801    /// All keys can be unset by posting an empty value to `metadata`.
802    pub fn metadata(
803        mut self,
804        metadata: impl Into<std::collections::HashMap<String, String>>,
805    ) -> Self {
806        self.inner.metadata = Some(metadata.into());
807        self
808    }
809    /// Cardholder name.
810    pub fn name(mut self, name: impl Into<String>) -> Self {
811        self.inner.name = Some(name.into());
812        self
813    }
814}
815impl UpdateExternalAccount {
816    /// Send the request and return the deserialized response.
817    pub async fn send<C: StripeClient>(
818        &self,
819        client: &C,
820    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
821        self.customize().send(client).await
822    }
823
824    /// Send the request and return the deserialized response, blocking until completion.
825    pub fn send_blocking<C: StripeBlockingClient>(
826        &self,
827        client: &C,
828    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
829        self.customize().send_blocking(client)
830    }
831}
832
833impl StripeRequest for UpdateExternalAccount {
834    type Output = stripe_shared::ExternalAccount;
835
836    fn build(&self) -> RequestBuilder {
837        let account = &self.account;
838        let id = &self.id;
839        RequestBuilder::new(
840            StripeMethod::Post,
841            format!("/accounts/{account}/external_accounts/{id}"),
842        )
843        .form(&self.inner)
844    }
845}