stripe_shared/
person_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 PersonFutureRequirements {
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    /// Fields that need to be collected to keep the person's account enabled.
8    /// If not collected by the account's `future_requirements[current_deadline]`, these fields will transition to the main `requirements` hash, and may immediately become `past_due`, but the account may also be given a grace period depending on the account's enablement state prior to transition.
9    pub currently_due: Vec<String>,
10    /// Fields that are `currently_due` and need to be collected again because validation or verification failed.
11    pub errors: Vec<stripe_shared::AccountRequirementsError>,
12    /// Fields you must collect when all thresholds are reached.
13    /// As they become required, they appear in `currently_due` as well, and the account's `future_requirements[current_deadline]` becomes set.
14    pub eventually_due: Vec<String>,
15    /// Fields that weren't collected by the account's `requirements.current_deadline`.
16    /// These fields need to be collected to enable the person's account.
17    /// New fields will never appear here; `future_requirements.past_due` will always be a subset of `requirements.past_due`.
18    pub past_due: Vec<String>,
19    /// Fields that might become required depending on the results of verification or review.
20    /// It's an empty array unless an asynchronous verification is pending.
21    /// If verification fails, these fields move to `eventually_due` or `currently_due`.
22    /// Fields might appear in `eventually_due` or `currently_due` and in `pending_verification` if verification fails but another verification is still pending.
23    pub pending_verification: Vec<String>,
24}
25#[doc(hidden)]
26pub struct PersonFutureRequirementsBuilder {
27    alternatives: Option<Option<Vec<stripe_shared::AccountRequirementsAlternative>>>,
28    currently_due: Option<Vec<String>>,
29    errors: Option<Vec<stripe_shared::AccountRequirementsError>>,
30    eventually_due: Option<Vec<String>>,
31    past_due: Option<Vec<String>>,
32    pending_verification: Option<Vec<String>>,
33}
34
35#[allow(
36    unused_variables,
37    irrefutable_let_patterns,
38    clippy::let_unit_value,
39    clippy::match_single_binding,
40    clippy::single_match
41)]
42const _: () = {
43    use miniserde::de::{Map, Visitor};
44    use miniserde::json::Value;
45    use miniserde::{Deserialize, Result, make_place};
46    use stripe_types::miniserde_helpers::FromValueOpt;
47    use stripe_types::{MapBuilder, ObjectDeser};
48
49    make_place!(Place);
50
51    impl Deserialize for PersonFutureRequirements {
52        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
53            Place::new(out)
54        }
55    }
56
57    struct Builder<'a> {
58        out: &'a mut Option<PersonFutureRequirements>,
59        builder: PersonFutureRequirementsBuilder,
60    }
61
62    impl Visitor for Place<PersonFutureRequirements> {
63        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
64            Ok(Box::new(Builder {
65                out: &mut self.out,
66                builder: PersonFutureRequirementsBuilder::deser_default(),
67            }))
68        }
69    }
70
71    impl MapBuilder for PersonFutureRequirementsBuilder {
72        type Out = PersonFutureRequirements;
73        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
74            Ok(match k {
75                "alternatives" => Deserialize::begin(&mut self.alternatives),
76                "currently_due" => Deserialize::begin(&mut self.currently_due),
77                "errors" => Deserialize::begin(&mut self.errors),
78                "eventually_due" => Deserialize::begin(&mut self.eventually_due),
79                "past_due" => Deserialize::begin(&mut self.past_due),
80                "pending_verification" => Deserialize::begin(&mut self.pending_verification),
81
82                _ => <dyn Visitor>::ignore(),
83            })
84        }
85
86        fn deser_default() -> Self {
87            Self {
88                alternatives: Deserialize::default(),
89                currently_due: Deserialize::default(),
90                errors: Deserialize::default(),
91                eventually_due: Deserialize::default(),
92                past_due: Deserialize::default(),
93                pending_verification: Deserialize::default(),
94            }
95        }
96
97        fn take_out(&mut self) -> Option<Self::Out> {
98            let (
99                Some(alternatives),
100                Some(currently_due),
101                Some(errors),
102                Some(eventually_due),
103                Some(past_due),
104                Some(pending_verification),
105            ) = (
106                self.alternatives.take(),
107                self.currently_due.take(),
108                self.errors.take(),
109                self.eventually_due.take(),
110                self.past_due.take(),
111                self.pending_verification.take(),
112            )
113            else {
114                return None;
115            };
116            Some(Self::Out {
117                alternatives,
118                currently_due,
119                errors,
120                eventually_due,
121                past_due,
122                pending_verification,
123            })
124        }
125    }
126
127    impl Map for Builder<'_> {
128        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
129            self.builder.key(k)
130        }
131
132        fn finish(&mut self) -> Result<()> {
133            *self.out = self.builder.take_out();
134            Ok(())
135        }
136    }
137
138    impl ObjectDeser for PersonFutureRequirements {
139        type Builder = PersonFutureRequirementsBuilder;
140    }
141
142    impl FromValueOpt for PersonFutureRequirements {
143        fn from_value(v: Value) -> Option<Self> {
144            let Value::Object(obj) = v else {
145                return None;
146            };
147            let mut b = PersonFutureRequirementsBuilder::deser_default();
148            for (k, v) in obj {
149                match k.as_str() {
150                    "alternatives" => b.alternatives = FromValueOpt::from_value(v),
151                    "currently_due" => b.currently_due = FromValueOpt::from_value(v),
152                    "errors" => b.errors = FromValueOpt::from_value(v),
153                    "eventually_due" => b.eventually_due = FromValueOpt::from_value(v),
154                    "past_due" => b.past_due = FromValueOpt::from_value(v),
155                    "pending_verification" => b.pending_verification = FromValueOpt::from_value(v),
156
157                    _ => {}
158                }
159            }
160            b.take_out()
161        }
162    }
163};