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