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 resolved by providing the corresponding alternative fields instead.
6    /// Many alternatives can list the same `original_fields_due`, and any of these alternatives can serve as a pathway for attempting to resolve the fields again.
7    /// Re-providing `original_fields_due` also serves as a pathway for attempting to resolve the fields again.
8    pub alternatives: Option<Vec<stripe_shared::AccountRequirementsAlternative>>,
9    /// Fields that need to be resolved to keep the person's account enabled.
10    /// If not resolved 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.
11    pub currently_due: Vec<String>,
12    /// Details about validation and verification failures for `due` requirements that must be resolved.
13    pub errors: Vec<stripe_shared::AccountRequirementsError>,
14    /// Fields you must collect when all thresholds are reached.
15    /// As they become required, they appear in `currently_due` as well, and the account's `future_requirements[current_deadline]` becomes set.
16    pub eventually_due: Vec<String>,
17    /// Fields that haven't been resolved by the account's `requirements.current_deadline`.
18    /// These fields need to be resolved to enable the person's account.
19    /// `future_requirements.past_due` is a subset of `requirements.past_due`.
20    pub past_due: Vec<String>,
21    /// Fields that are being reviewed, or might become required depending on the results of a review.
22    /// If the review fails, these fields can move to `eventually_due`, `currently_due`, `past_due` or `alternatives`.
23    /// Fields might appear in `eventually_due`, `currently_due`, `past_due` or `alternatives` and in `pending_verification` if one verification fails but another is still pending.
24    pub pending_verification: Vec<String>,
25}
26#[doc(hidden)]
27pub struct PersonFutureRequirementsBuilder {
28    alternatives: Option<Option<Vec<stripe_shared::AccountRequirementsAlternative>>>,
29    currently_due: Option<Vec<String>>,
30    errors: Option<Vec<stripe_shared::AccountRequirementsError>>,
31    eventually_due: Option<Vec<String>>,
32    past_due: Option<Vec<String>>,
33    pending_verification: Option<Vec<String>>,
34}
35
36#[allow(
37    unused_variables,
38    irrefutable_let_patterns,
39    clippy::let_unit_value,
40    clippy::match_single_binding,
41    clippy::single_match
42)]
43const _: () = {
44    use miniserde::de::{Map, Visitor};
45    use miniserde::json::Value;
46    use miniserde::{Deserialize, Result, make_place};
47    use stripe_types::miniserde_helpers::FromValueOpt;
48    use stripe_types::{MapBuilder, ObjectDeser};
49
50    make_place!(Place);
51
52    impl Deserialize for PersonFutureRequirements {
53        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
54            Place::new(out)
55        }
56    }
57
58    struct Builder<'a> {
59        out: &'a mut Option<PersonFutureRequirements>,
60        builder: PersonFutureRequirementsBuilder,
61    }
62
63    impl Visitor for Place<PersonFutureRequirements> {
64        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
65            Ok(Box::new(Builder {
66                out: &mut self.out,
67                builder: PersonFutureRequirementsBuilder::deser_default(),
68            }))
69        }
70    }
71
72    impl MapBuilder for PersonFutureRequirementsBuilder {
73        type Out = PersonFutureRequirements;
74        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
75            Ok(match k {
76                "alternatives" => Deserialize::begin(&mut self.alternatives),
77                "currently_due" => Deserialize::begin(&mut self.currently_due),
78                "errors" => Deserialize::begin(&mut self.errors),
79                "eventually_due" => Deserialize::begin(&mut self.eventually_due),
80                "past_due" => Deserialize::begin(&mut self.past_due),
81                "pending_verification" => Deserialize::begin(&mut self.pending_verification),
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            b.take_out()
160        }
161    }
162};