stripe_shared/
account_capability_requirements.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct AccountCapabilityRequirements {
5    /// Fields that are due and can be satisfied by providing the corresponding alternative fields instead.
6    pub alternatives: Option<Vec<stripe_shared::AccountRequirementsAlternative>>,
7    /// The date by which all required account information must be both submitted and verified.
8    /// This includes fields listed in `currently_due` as well as those in `pending_verification`.
9    /// If any required information is missing or unverified by this date, the account may be disabled.
10    /// Note that `current_deadline` may change if additional `currently_due` requirements are requested.
11    pub current_deadline: Option<stripe_types::Timestamp>,
12    /// Fields that need to be collected to keep the capability enabled.
13    /// If not collected by `current_deadline`, these fields appear in `past_due` as well, and the capability is disabled.
14    pub currently_due: Vec<String>,
15    /// Description of why the capability is disabled.
16    /// [Learn more about handling verification issues](https://stripe.com/docs/connect/handling-api-verification).
17    pub disabled_reason: Option<AccountCapabilityRequirementsDisabledReason>,
18    /// Fields that are `currently_due` and need to be collected again because validation or verification failed.
19    pub errors: Vec<stripe_shared::AccountRequirementsError>,
20    /// Fields you must collect when all thresholds are reached.
21    /// As they become required, they appear in `currently_due` as well, and `current_deadline` becomes set.
22    pub eventually_due: Vec<String>,
23    /// Fields that weren't collected by `current_deadline`.
24    /// These fields need to be collected to enable the capability on the account.
25    pub past_due: Vec<String>,
26    /// Fields that might become required depending on the results of verification or review.
27    /// It's an empty array unless an asynchronous verification is pending.
28    /// If verification fails, these fields move to `eventually_due`, `currently_due`, or `past_due`.
29    /// Fields might appear in `eventually_due`, `currently_due`, or `past_due` and in `pending_verification` if verification fails but another verification is still pending.
30    pub pending_verification: Vec<String>,
31}
32#[doc(hidden)]
33pub struct AccountCapabilityRequirementsBuilder {
34    alternatives: Option<Option<Vec<stripe_shared::AccountRequirementsAlternative>>>,
35    current_deadline: Option<Option<stripe_types::Timestamp>>,
36    currently_due: Option<Vec<String>>,
37    disabled_reason: Option<Option<AccountCapabilityRequirementsDisabledReason>>,
38    errors: Option<Vec<stripe_shared::AccountRequirementsError>>,
39    eventually_due: Option<Vec<String>>,
40    past_due: Option<Vec<String>>,
41    pending_verification: Option<Vec<String>>,
42}
43
44#[allow(
45    unused_variables,
46    irrefutable_let_patterns,
47    clippy::let_unit_value,
48    clippy::match_single_binding,
49    clippy::single_match
50)]
51const _: () = {
52    use miniserde::de::{Map, Visitor};
53    use miniserde::json::Value;
54    use miniserde::{Deserialize, Result, make_place};
55    use stripe_types::miniserde_helpers::FromValueOpt;
56    use stripe_types::{MapBuilder, ObjectDeser};
57
58    make_place!(Place);
59
60    impl Deserialize for AccountCapabilityRequirements {
61        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
62            Place::new(out)
63        }
64    }
65
66    struct Builder<'a> {
67        out: &'a mut Option<AccountCapabilityRequirements>,
68        builder: AccountCapabilityRequirementsBuilder,
69    }
70
71    impl Visitor for Place<AccountCapabilityRequirements> {
72        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
73            Ok(Box::new(Builder {
74                out: &mut self.out,
75                builder: AccountCapabilityRequirementsBuilder::deser_default(),
76            }))
77        }
78    }
79
80    impl MapBuilder for AccountCapabilityRequirementsBuilder {
81        type Out = AccountCapabilityRequirements;
82        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
83            Ok(match k {
84                "alternatives" => Deserialize::begin(&mut self.alternatives),
85                "current_deadline" => Deserialize::begin(&mut self.current_deadline),
86                "currently_due" => Deserialize::begin(&mut self.currently_due),
87                "disabled_reason" => Deserialize::begin(&mut self.disabled_reason),
88                "errors" => Deserialize::begin(&mut self.errors),
89                "eventually_due" => Deserialize::begin(&mut self.eventually_due),
90                "past_due" => Deserialize::begin(&mut self.past_due),
91                "pending_verification" => Deserialize::begin(&mut self.pending_verification),
92                _ => <dyn Visitor>::ignore(),
93            })
94        }
95
96        fn deser_default() -> Self {
97            Self {
98                alternatives: Deserialize::default(),
99                current_deadline: Deserialize::default(),
100                currently_due: Deserialize::default(),
101                disabled_reason: Deserialize::default(),
102                errors: Deserialize::default(),
103                eventually_due: Deserialize::default(),
104                past_due: Deserialize::default(),
105                pending_verification: Deserialize::default(),
106            }
107        }
108
109        fn take_out(&mut self) -> Option<Self::Out> {
110            let (
111                Some(alternatives),
112                Some(current_deadline),
113                Some(currently_due),
114                Some(disabled_reason),
115                Some(errors),
116                Some(eventually_due),
117                Some(past_due),
118                Some(pending_verification),
119            ) = (
120                self.alternatives.take(),
121                self.current_deadline,
122                self.currently_due.take(),
123                self.disabled_reason,
124                self.errors.take(),
125                self.eventually_due.take(),
126                self.past_due.take(),
127                self.pending_verification.take(),
128            )
129            else {
130                return None;
131            };
132            Some(Self::Out {
133                alternatives,
134                current_deadline,
135                currently_due,
136                disabled_reason,
137                errors,
138                eventually_due,
139                past_due,
140                pending_verification,
141            })
142        }
143    }
144
145    impl Map for Builder<'_> {
146        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
147            self.builder.key(k)
148        }
149
150        fn finish(&mut self) -> Result<()> {
151            *self.out = self.builder.take_out();
152            Ok(())
153        }
154    }
155
156    impl ObjectDeser for AccountCapabilityRequirements {
157        type Builder = AccountCapabilityRequirementsBuilder;
158    }
159
160    impl FromValueOpt for AccountCapabilityRequirements {
161        fn from_value(v: Value) -> Option<Self> {
162            let Value::Object(obj) = v else {
163                return None;
164            };
165            let mut b = AccountCapabilityRequirementsBuilder::deser_default();
166            for (k, v) in obj {
167                match k.as_str() {
168                    "alternatives" => b.alternatives = FromValueOpt::from_value(v),
169                    "current_deadline" => b.current_deadline = FromValueOpt::from_value(v),
170                    "currently_due" => b.currently_due = FromValueOpt::from_value(v),
171                    "disabled_reason" => b.disabled_reason = FromValueOpt::from_value(v),
172                    "errors" => b.errors = FromValueOpt::from_value(v),
173                    "eventually_due" => b.eventually_due = FromValueOpt::from_value(v),
174                    "past_due" => b.past_due = FromValueOpt::from_value(v),
175                    "pending_verification" => b.pending_verification = FromValueOpt::from_value(v),
176                    _ => {}
177                }
178            }
179            b.take_out()
180        }
181    }
182};
183/// Description of why the capability is disabled.
184/// [Learn more about handling verification issues](https://stripe.com/docs/connect/handling-api-verification).
185#[derive(Copy, Clone, Eq, PartialEq)]
186pub enum AccountCapabilityRequirementsDisabledReason {
187    Other,
188    PausedInactivity,
189    PendingOnboarding,
190    PendingReview,
191    PlatformDisabled,
192    PlatformPaused,
193    RejectedInactivity,
194    RejectedOther,
195    RejectedUnsupportedBusiness,
196    RequirementsFieldsNeeded,
197}
198impl AccountCapabilityRequirementsDisabledReason {
199    pub fn as_str(self) -> &'static str {
200        use AccountCapabilityRequirementsDisabledReason::*;
201        match self {
202            Other => "other",
203            PausedInactivity => "paused.inactivity",
204            PendingOnboarding => "pending.onboarding",
205            PendingReview => "pending.review",
206            PlatformDisabled => "platform_disabled",
207            PlatformPaused => "platform_paused",
208            RejectedInactivity => "rejected.inactivity",
209            RejectedOther => "rejected.other",
210            RejectedUnsupportedBusiness => "rejected.unsupported_business",
211            RequirementsFieldsNeeded => "requirements.fields_needed",
212        }
213    }
214}
215
216impl std::str::FromStr for AccountCapabilityRequirementsDisabledReason {
217    type Err = stripe_types::StripeParseError;
218    fn from_str(s: &str) -> Result<Self, Self::Err> {
219        use AccountCapabilityRequirementsDisabledReason::*;
220        match s {
221            "other" => Ok(Other),
222            "paused.inactivity" => Ok(PausedInactivity),
223            "pending.onboarding" => Ok(PendingOnboarding),
224            "pending.review" => Ok(PendingReview),
225            "platform_disabled" => Ok(PlatformDisabled),
226            "platform_paused" => Ok(PlatformPaused),
227            "rejected.inactivity" => Ok(RejectedInactivity),
228            "rejected.other" => Ok(RejectedOther),
229            "rejected.unsupported_business" => Ok(RejectedUnsupportedBusiness),
230            "requirements.fields_needed" => Ok(RequirementsFieldsNeeded),
231            _ => Err(stripe_types::StripeParseError),
232        }
233    }
234}
235impl std::fmt::Display for AccountCapabilityRequirementsDisabledReason {
236    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
237        f.write_str(self.as_str())
238    }
239}
240
241impl std::fmt::Debug for AccountCapabilityRequirementsDisabledReason {
242    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
243        f.write_str(self.as_str())
244    }
245}
246#[cfg(feature = "serialize")]
247impl serde::Serialize for AccountCapabilityRequirementsDisabledReason {
248    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
249    where
250        S: serde::Serializer,
251    {
252        serializer.serialize_str(self.as_str())
253    }
254}
255impl miniserde::Deserialize for AccountCapabilityRequirementsDisabledReason {
256    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
257        crate::Place::new(out)
258    }
259}
260
261impl miniserde::de::Visitor for crate::Place<AccountCapabilityRequirementsDisabledReason> {
262    fn string(&mut self, s: &str) -> miniserde::Result<()> {
263        use std::str::FromStr;
264        self.out = Some(
265            AccountCapabilityRequirementsDisabledReason::from_str(s)
266                .map_err(|_| miniserde::Error)?,
267        );
268        Ok(())
269    }
270}
271
272stripe_types::impl_from_val_with_from_str!(AccountCapabilityRequirementsDisabledReason);
273#[cfg(feature = "deserialize")]
274impl<'de> serde::Deserialize<'de> for AccountCapabilityRequirementsDisabledReason {
275    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
276        use std::str::FromStr;
277        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
278        Self::from_str(&s).map_err(|_| {
279            serde::de::Error::custom(
280                "Unknown value for AccountCapabilityRequirementsDisabledReason",
281            )
282        })
283    }
284}