1#[derive(Clone, Eq, PartialEq)]
2#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
3#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
4#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
5pub struct AccountUnificationAccountController {
6 pub fees: Option<stripe_shared::AccountUnificationAccountControllerFees>,
7 pub is_controller: Option<bool>,
10 pub losses: Option<stripe_shared::AccountUnificationAccountControllerLosses>,
11 pub requirement_collection: Option<AccountUnificationAccountControllerRequirementCollection>,
14 pub stripe_dashboard: Option<stripe_shared::AccountUnificationAccountControllerStripeDashboard>,
15 #[cfg_attr(any(feature = "deserialize", feature = "serialize"), serde(rename = "type"))]
18 pub type_: AccountUnificationAccountControllerType,
19}
20#[cfg(feature = "redact-generated-debug")]
21impl std::fmt::Debug for AccountUnificationAccountController {
22 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
23 f.debug_struct("AccountUnificationAccountController").finish_non_exhaustive()
24 }
25}
26#[doc(hidden)]
27pub struct AccountUnificationAccountControllerBuilder {
28 fees: Option<Option<stripe_shared::AccountUnificationAccountControllerFees>>,
29 is_controller: Option<Option<bool>>,
30 losses: Option<Option<stripe_shared::AccountUnificationAccountControllerLosses>>,
31 requirement_collection:
32 Option<Option<AccountUnificationAccountControllerRequirementCollection>>,
33 stripe_dashboard:
34 Option<Option<stripe_shared::AccountUnificationAccountControllerStripeDashboard>>,
35 type_: Option<AccountUnificationAccountControllerType>,
36}
37
38#[allow(
39 unused_variables,
40 irrefutable_let_patterns,
41 clippy::let_unit_value,
42 clippy::match_single_binding,
43 clippy::single_match
44)]
45const _: () = {
46 use miniserde::de::{Map, Visitor};
47 use miniserde::json::Value;
48 use miniserde::{Deserialize, Result, make_place};
49 use stripe_types::miniserde_helpers::FromValueOpt;
50 use stripe_types::{MapBuilder, ObjectDeser};
51
52 make_place!(Place);
53
54 impl Deserialize for AccountUnificationAccountController {
55 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
56 Place::new(out)
57 }
58 }
59
60 struct Builder<'a> {
61 out: &'a mut Option<AccountUnificationAccountController>,
62 builder: AccountUnificationAccountControllerBuilder,
63 }
64
65 impl Visitor for Place<AccountUnificationAccountController> {
66 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
67 Ok(Box::new(Builder {
68 out: &mut self.out,
69 builder: AccountUnificationAccountControllerBuilder::deser_default(),
70 }))
71 }
72 }
73
74 impl MapBuilder for AccountUnificationAccountControllerBuilder {
75 type Out = AccountUnificationAccountController;
76 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
77 Ok(match k {
78 "fees" => Deserialize::begin(&mut self.fees),
79 "is_controller" => Deserialize::begin(&mut self.is_controller),
80 "losses" => Deserialize::begin(&mut self.losses),
81 "requirement_collection" => Deserialize::begin(&mut self.requirement_collection),
82 "stripe_dashboard" => Deserialize::begin(&mut self.stripe_dashboard),
83 "type" => Deserialize::begin(&mut self.type_),
84 _ => <dyn Visitor>::ignore(),
85 })
86 }
87
88 fn deser_default() -> Self {
89 Self {
90 fees: Some(None),
91 is_controller: Some(None),
92 losses: Some(None),
93 requirement_collection: Some(None),
94 stripe_dashboard: Some(None),
95 type_: None,
96 }
97 }
98
99 fn take_out(&mut self) -> Option<Self::Out> {
100 let (
101 Some(fees),
102 Some(is_controller),
103 Some(losses),
104 Some(requirement_collection),
105 Some(stripe_dashboard),
106 Some(type_),
107 ) = (
108 self.fees.take(),
109 self.is_controller,
110 self.losses.take(),
111 self.requirement_collection.take(),
112 self.stripe_dashboard.take(),
113 self.type_.take(),
114 )
115 else {
116 return None;
117 };
118 Some(Self::Out {
119 fees,
120 is_controller,
121 losses,
122 requirement_collection,
123 stripe_dashboard,
124 type_,
125 })
126 }
127 }
128
129 impl Map for Builder<'_> {
130 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
131 self.builder.key(k)
132 }
133
134 fn finish(&mut self) -> Result<()> {
135 *self.out = self.builder.take_out();
136 Ok(())
137 }
138 }
139
140 impl ObjectDeser for AccountUnificationAccountController {
141 type Builder = AccountUnificationAccountControllerBuilder;
142 }
143
144 impl FromValueOpt for AccountUnificationAccountController {
145 fn from_value(v: Value) -> Option<Self> {
146 let Value::Object(obj) = v else {
147 return None;
148 };
149 let mut b = AccountUnificationAccountControllerBuilder::deser_default();
150 for (k, v) in obj {
151 match k.as_str() {
152 "fees" => b.fees = FromValueOpt::from_value(v),
153 "is_controller" => b.is_controller = FromValueOpt::from_value(v),
154 "losses" => b.losses = FromValueOpt::from_value(v),
155 "requirement_collection" => {
156 b.requirement_collection = FromValueOpt::from_value(v)
157 }
158 "stripe_dashboard" => b.stripe_dashboard = FromValueOpt::from_value(v),
159 "type" => b.type_ = FromValueOpt::from_value(v),
160 _ => {}
161 }
162 }
163 b.take_out()
164 }
165 }
166};
167#[derive(Clone, Eq, PartialEq)]
170#[non_exhaustive]
171pub enum AccountUnificationAccountControllerRequirementCollection {
172 Application,
173 Stripe,
174 Unknown(String),
176}
177impl AccountUnificationAccountControllerRequirementCollection {
178 pub fn as_str(&self) -> &str {
179 use AccountUnificationAccountControllerRequirementCollection::*;
180 match self {
181 Application => "application",
182 Stripe => "stripe",
183 Unknown(v) => v,
184 }
185 }
186}
187
188impl std::str::FromStr for AccountUnificationAccountControllerRequirementCollection {
189 type Err = std::convert::Infallible;
190 fn from_str(s: &str) -> Result<Self, Self::Err> {
191 use AccountUnificationAccountControllerRequirementCollection::*;
192 match s {
193 "application" => Ok(Application),
194 "stripe" => Ok(Stripe),
195 v => {
196 tracing::warn!(
197 "Unknown value '{}' for enum '{}'",
198 v,
199 "AccountUnificationAccountControllerRequirementCollection"
200 );
201 Ok(Unknown(v.to_owned()))
202 }
203 }
204 }
205}
206impl std::fmt::Display for AccountUnificationAccountControllerRequirementCollection {
207 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
208 f.write_str(self.as_str())
209 }
210}
211
212#[cfg(not(feature = "redact-generated-debug"))]
213impl std::fmt::Debug for AccountUnificationAccountControllerRequirementCollection {
214 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
215 f.write_str(self.as_str())
216 }
217}
218#[cfg(feature = "redact-generated-debug")]
219impl std::fmt::Debug for AccountUnificationAccountControllerRequirementCollection {
220 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
221 f.debug_struct(stringify!(AccountUnificationAccountControllerRequirementCollection))
222 .finish_non_exhaustive()
223 }
224}
225#[cfg(feature = "serialize")]
226impl serde::Serialize for AccountUnificationAccountControllerRequirementCollection {
227 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
228 where
229 S: serde::Serializer,
230 {
231 serializer.serialize_str(self.as_str())
232 }
233}
234impl miniserde::Deserialize for AccountUnificationAccountControllerRequirementCollection {
235 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
236 crate::Place::new(out)
237 }
238}
239
240impl miniserde::de::Visitor
241 for crate::Place<AccountUnificationAccountControllerRequirementCollection>
242{
243 fn string(&mut self, s: &str) -> miniserde::Result<()> {
244 use std::str::FromStr;
245 self.out = Some(
246 AccountUnificationAccountControllerRequirementCollection::from_str(s)
247 .expect("infallible"),
248 );
249 Ok(())
250 }
251}
252
253stripe_types::impl_from_val_with_from_str!(
254 AccountUnificationAccountControllerRequirementCollection
255);
256#[cfg(feature = "deserialize")]
257impl<'de> serde::Deserialize<'de> for AccountUnificationAccountControllerRequirementCollection {
258 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
259 use std::str::FromStr;
260 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
261 Ok(Self::from_str(&s).expect("infallible"))
262 }
263}
264#[derive(Clone, Eq, PartialEq)]
267#[non_exhaustive]
268pub enum AccountUnificationAccountControllerType {
269 Account,
270 Application,
271 Unknown(String),
273}
274impl AccountUnificationAccountControllerType {
275 pub fn as_str(&self) -> &str {
276 use AccountUnificationAccountControllerType::*;
277 match self {
278 Account => "account",
279 Application => "application",
280 Unknown(v) => v,
281 }
282 }
283}
284
285impl std::str::FromStr for AccountUnificationAccountControllerType {
286 type Err = std::convert::Infallible;
287 fn from_str(s: &str) -> Result<Self, Self::Err> {
288 use AccountUnificationAccountControllerType::*;
289 match s {
290 "account" => Ok(Account),
291 "application" => Ok(Application),
292 v => {
293 tracing::warn!(
294 "Unknown value '{}' for enum '{}'",
295 v,
296 "AccountUnificationAccountControllerType"
297 );
298 Ok(Unknown(v.to_owned()))
299 }
300 }
301 }
302}
303impl std::fmt::Display for AccountUnificationAccountControllerType {
304 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
305 f.write_str(self.as_str())
306 }
307}
308
309#[cfg(not(feature = "redact-generated-debug"))]
310impl std::fmt::Debug for AccountUnificationAccountControllerType {
311 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
312 f.write_str(self.as_str())
313 }
314}
315#[cfg(feature = "redact-generated-debug")]
316impl std::fmt::Debug for AccountUnificationAccountControllerType {
317 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
318 f.debug_struct(stringify!(AccountUnificationAccountControllerType)).finish_non_exhaustive()
319 }
320}
321#[cfg(feature = "serialize")]
322impl serde::Serialize for AccountUnificationAccountControllerType {
323 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
324 where
325 S: serde::Serializer,
326 {
327 serializer.serialize_str(self.as_str())
328 }
329}
330impl miniserde::Deserialize for AccountUnificationAccountControllerType {
331 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
332 crate::Place::new(out)
333 }
334}
335
336impl miniserde::de::Visitor for crate::Place<AccountUnificationAccountControllerType> {
337 fn string(&mut self, s: &str) -> miniserde::Result<()> {
338 use std::str::FromStr;
339 self.out = Some(AccountUnificationAccountControllerType::from_str(s).expect("infallible"));
340 Ok(())
341 }
342}
343
344stripe_types::impl_from_val_with_from_str!(AccountUnificationAccountControllerType);
345#[cfg(feature = "deserialize")]
346impl<'de> serde::Deserialize<'de> for AccountUnificationAccountControllerType {
347 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
348 use std::str::FromStr;
349 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
350 Ok(Self::from_str(&s).expect("infallible"))
351 }
352}