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::{make_place, Deserialize, Result};
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
93                _ => <dyn Visitor>::ignore(),
94            })
95        }
96
97        fn deser_default() -> Self {
98            Self {
99                alternatives: Deserialize::default(),
100                current_deadline: Deserialize::default(),
101                currently_due: Deserialize::default(),
102                disabled_reason: Deserialize::default(),
103                errors: Deserialize::default(),
104                eventually_due: Deserialize::default(),
105                past_due: Deserialize::default(),
106                pending_verification: Deserialize::default(),
107            }
108        }
109
110        fn take_out(&mut self) -> Option<Self::Out> {
111            let (
112                Some(alternatives),
113                Some(current_deadline),
114                Some(currently_due),
115                Some(disabled_reason),
116                Some(errors),
117                Some(eventually_due),
118                Some(past_due),
119                Some(pending_verification),
120            ) = (
121                self.alternatives.take(),
122                self.current_deadline,
123                self.currently_due.take(),
124                self.disabled_reason,
125                self.errors.take(),
126                self.eventually_due.take(),
127                self.past_due.take(),
128                self.pending_verification.take(),
129            )
130            else {
131                return None;
132            };
133            Some(Self::Out {
134                alternatives,
135                current_deadline,
136                currently_due,
137                disabled_reason,
138                errors,
139                eventually_due,
140                past_due,
141                pending_verification,
142            })
143        }
144    }
145
146    impl Map for Builder<'_> {
147        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
148            self.builder.key(k)
149        }
150
151        fn finish(&mut self) -> Result<()> {
152            *self.out = self.builder.take_out();
153            Ok(())
154        }
155    }
156
157    impl ObjectDeser for AccountCapabilityRequirements {
158        type Builder = AccountCapabilityRequirementsBuilder;
159    }
160
161    impl FromValueOpt for AccountCapabilityRequirements {
162        fn from_value(v: Value) -> Option<Self> {
163            let Value::Object(obj) = v else {
164                return None;
165            };
166            let mut b = AccountCapabilityRequirementsBuilder::deser_default();
167            for (k, v) in obj {
168                match k.as_str() {
169                    "alternatives" => b.alternatives = FromValueOpt::from_value(v),
170                    "current_deadline" => b.current_deadline = FromValueOpt::from_value(v),
171                    "currently_due" => b.currently_due = FromValueOpt::from_value(v),
172                    "disabled_reason" => b.disabled_reason = FromValueOpt::from_value(v),
173                    "errors" => b.errors = FromValueOpt::from_value(v),
174                    "eventually_due" => b.eventually_due = FromValueOpt::from_value(v),
175                    "past_due" => b.past_due = FromValueOpt::from_value(v),
176                    "pending_verification" => b.pending_verification = FromValueOpt::from_value(v),
177
178                    _ => {}
179                }
180            }
181            b.take_out()
182        }
183    }
184};
185/// Description of why the capability is disabled.
186/// [Learn more about handling verification issues](https://stripe.com/docs/connect/handling-api-verification).
187#[derive(Copy, Clone, Eq, PartialEq)]
188pub enum AccountCapabilityRequirementsDisabledReason {
189    Other,
190    PausedInactivity,
191    PendingOnboarding,
192    PendingReview,
193    PlatformDisabled,
194    PlatformPaused,
195    RejectedInactivity,
196    RejectedOther,
197    RejectedUnsupportedBusiness,
198    RequirementsFieldsNeeded,
199}
200impl AccountCapabilityRequirementsDisabledReason {
201    pub fn as_str(self) -> &'static str {
202        use AccountCapabilityRequirementsDisabledReason::*;
203        match self {
204            Other => "other",
205            PausedInactivity => "paused.inactivity",
206            PendingOnboarding => "pending.onboarding",
207            PendingReview => "pending.review",
208            PlatformDisabled => "platform_disabled",
209            PlatformPaused => "platform_paused",
210            RejectedInactivity => "rejected.inactivity",
211            RejectedOther => "rejected.other",
212            RejectedUnsupportedBusiness => "rejected.unsupported_business",
213            RequirementsFieldsNeeded => "requirements.fields_needed",
214        }
215    }
216}
217
218impl std::str::FromStr for AccountCapabilityRequirementsDisabledReason {
219    type Err = stripe_types::StripeParseError;
220    fn from_str(s: &str) -> Result<Self, Self::Err> {
221        use AccountCapabilityRequirementsDisabledReason::*;
222        match s {
223            "other" => Ok(Other),
224            "paused.inactivity" => Ok(PausedInactivity),
225            "pending.onboarding" => Ok(PendingOnboarding),
226            "pending.review" => Ok(PendingReview),
227            "platform_disabled" => Ok(PlatformDisabled),
228            "platform_paused" => Ok(PlatformPaused),
229            "rejected.inactivity" => Ok(RejectedInactivity),
230            "rejected.other" => Ok(RejectedOther),
231            "rejected.unsupported_business" => Ok(RejectedUnsupportedBusiness),
232            "requirements.fields_needed" => Ok(RequirementsFieldsNeeded),
233            _ => Err(stripe_types::StripeParseError),
234        }
235    }
236}
237impl std::fmt::Display for AccountCapabilityRequirementsDisabledReason {
238    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
239        f.write_str(self.as_str())
240    }
241}
242
243impl std::fmt::Debug for AccountCapabilityRequirementsDisabledReason {
244    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
245        f.write_str(self.as_str())
246    }
247}
248#[cfg(feature = "serialize")]
249impl serde::Serialize for AccountCapabilityRequirementsDisabledReason {
250    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
251    where
252        S: serde::Serializer,
253    {
254        serializer.serialize_str(self.as_str())
255    }
256}
257impl miniserde::Deserialize for AccountCapabilityRequirementsDisabledReason {
258    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
259        crate::Place::new(out)
260    }
261}
262
263impl miniserde::de::Visitor for crate::Place<AccountCapabilityRequirementsDisabledReason> {
264    fn string(&mut self, s: &str) -> miniserde::Result<()> {
265        use std::str::FromStr;
266        self.out = Some(
267            AccountCapabilityRequirementsDisabledReason::from_str(s)
268                .map_err(|_| miniserde::Error)?,
269        );
270        Ok(())
271    }
272}
273
274stripe_types::impl_from_val_with_from_str!(AccountCapabilityRequirementsDisabledReason);
275#[cfg(feature = "deserialize")]
276impl<'de> serde::Deserialize<'de> for AccountCapabilityRequirementsDisabledReason {
277    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
278        use std::str::FromStr;
279        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
280        Self::from_str(&s).map_err(|_| {
281            serde::de::Error::custom(
282                "Unknown value for AccountCapabilityRequirementsDisabledReason",
283            )
284        })
285    }
286}