1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct AccountFutureRequirements {
5 pub alternatives: Option<Vec<stripe_shared::AccountRequirementsAlternative>>,
7 pub current_deadline: Option<stripe_types::Timestamp>,
10 pub currently_due: Option<Vec<String>>,
13 pub disabled_reason: Option<AccountFutureRequirementsDisabledReason>,
15 pub errors: Option<Vec<stripe_shared::AccountRequirementsError>>,
17 pub eventually_due: Option<Vec<String>>,
20 pub past_due: Option<Vec<String>>,
24 pub pending_verification: Option<Vec<String>>,
29}
30#[doc(hidden)]
31pub struct AccountFutureRequirementsBuilder {
32 alternatives: Option<Option<Vec<stripe_shared::AccountRequirementsAlternative>>>,
33 current_deadline: Option<Option<stripe_types::Timestamp>>,
34 currently_due: Option<Option<Vec<String>>>,
35 disabled_reason: Option<Option<AccountFutureRequirementsDisabledReason>>,
36 errors: Option<Option<Vec<stripe_shared::AccountRequirementsError>>>,
37 eventually_due: Option<Option<Vec<String>>>,
38 past_due: Option<Option<Vec<String>>>,
39 pending_verification: Option<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 AccountFutureRequirements {
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<AccountFutureRequirements>,
66 builder: AccountFutureRequirementsBuilder,
67 }
68
69 impl Visitor for Place<AccountFutureRequirements> {
70 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
71 Ok(Box::new(Builder {
72 out: &mut self.out,
73 builder: AccountFutureRequirementsBuilder::deser_default(),
74 }))
75 }
76 }
77
78 impl MapBuilder for AccountFutureRequirementsBuilder {
79 type Out = AccountFutureRequirements;
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 AccountFutureRequirements {
155 type Builder = AccountFutureRequirementsBuilder;
156 }
157
158 impl FromValueOpt for AccountFutureRequirements {
159 fn from_value(v: Value) -> Option<Self> {
160 let Value::Object(obj) = v else {
161 return None;
162 };
163 let mut b = AccountFutureRequirementsBuilder::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#[derive(Clone, Eq, PartialEq)]
183#[non_exhaustive]
184pub enum AccountFutureRequirementsDisabledReason {
185 ActionRequiredRequestedCapabilities,
186 Listed,
187 Other,
188 PlatformPaused,
189 RejectedFraud,
190 RejectedIncompleteVerification,
191 RejectedListed,
192 RejectedOther,
193 RejectedPlatformFraud,
194 RejectedPlatformOther,
195 RejectedPlatformTermsOfService,
196 RejectedTermsOfService,
197 RequirementsPastDue,
198 RequirementsPendingVerification,
199 UnderReview,
200 Unknown(String),
202}
203impl AccountFutureRequirementsDisabledReason {
204 pub fn as_str(&self) -> &str {
205 use AccountFutureRequirementsDisabledReason::*;
206 match self {
207 ActionRequiredRequestedCapabilities => "action_required.requested_capabilities",
208 Listed => "listed",
209 Other => "other",
210 PlatformPaused => "platform_paused",
211 RejectedFraud => "rejected.fraud",
212 RejectedIncompleteVerification => "rejected.incomplete_verification",
213 RejectedListed => "rejected.listed",
214 RejectedOther => "rejected.other",
215 RejectedPlatformFraud => "rejected.platform_fraud",
216 RejectedPlatformOther => "rejected.platform_other",
217 RejectedPlatformTermsOfService => "rejected.platform_terms_of_service",
218 RejectedTermsOfService => "rejected.terms_of_service",
219 RequirementsPastDue => "requirements.past_due",
220 RequirementsPendingVerification => "requirements.pending_verification",
221 UnderReview => "under_review",
222 Unknown(v) => v,
223 }
224 }
225}
226
227impl std::str::FromStr for AccountFutureRequirementsDisabledReason {
228 type Err = std::convert::Infallible;
229 fn from_str(s: &str) -> Result<Self, Self::Err> {
230 use AccountFutureRequirementsDisabledReason::*;
231 match s {
232 "action_required.requested_capabilities" => Ok(ActionRequiredRequestedCapabilities),
233 "listed" => Ok(Listed),
234 "other" => Ok(Other),
235 "platform_paused" => Ok(PlatformPaused),
236 "rejected.fraud" => Ok(RejectedFraud),
237 "rejected.incomplete_verification" => Ok(RejectedIncompleteVerification),
238 "rejected.listed" => Ok(RejectedListed),
239 "rejected.other" => Ok(RejectedOther),
240 "rejected.platform_fraud" => Ok(RejectedPlatformFraud),
241 "rejected.platform_other" => Ok(RejectedPlatformOther),
242 "rejected.platform_terms_of_service" => Ok(RejectedPlatformTermsOfService),
243 "rejected.terms_of_service" => Ok(RejectedTermsOfService),
244 "requirements.past_due" => Ok(RequirementsPastDue),
245 "requirements.pending_verification" => Ok(RequirementsPendingVerification),
246 "under_review" => Ok(UnderReview),
247 v => {
248 tracing::warn!(
249 "Unknown value '{}' for enum '{}'",
250 v,
251 "AccountFutureRequirementsDisabledReason"
252 );
253 Ok(Unknown(v.to_owned()))
254 }
255 }
256 }
257}
258impl std::fmt::Display for AccountFutureRequirementsDisabledReason {
259 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
260 f.write_str(self.as_str())
261 }
262}
263
264impl std::fmt::Debug for AccountFutureRequirementsDisabledReason {
265 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
266 f.write_str(self.as_str())
267 }
268}
269#[cfg(feature = "serialize")]
270impl serde::Serialize for AccountFutureRequirementsDisabledReason {
271 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
272 where
273 S: serde::Serializer,
274 {
275 serializer.serialize_str(self.as_str())
276 }
277}
278impl miniserde::Deserialize for AccountFutureRequirementsDisabledReason {
279 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
280 crate::Place::new(out)
281 }
282}
283
284impl miniserde::de::Visitor for crate::Place<AccountFutureRequirementsDisabledReason> {
285 fn string(&mut self, s: &str) -> miniserde::Result<()> {
286 use std::str::FromStr;
287 self.out = Some(AccountFutureRequirementsDisabledReason::from_str(s).expect("infallible"));
288 Ok(())
289 }
290}
291
292stripe_types::impl_from_val_with_from_str!(AccountFutureRequirementsDisabledReason);
293#[cfg(feature = "deserialize")]
294impl<'de> serde::Deserialize<'de> for AccountFutureRequirementsDisabledReason {
295 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
296 use std::str::FromStr;
297 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
298 Ok(Self::from_str(&s).expect("infallible"))
299 }
300}