stripe_shared/
account_capability_future_requirements.rs

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