1#[derive(Clone, Debug)]
3#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
4#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
5pub struct GelatoDocumentReport {
6 pub address: Option<stripe_shared::Address>,
8 pub dob: Option<stripe_misc::GelatoDataDocumentReportDateOfBirth>,
10 pub error: Option<stripe_misc::GelatoDocumentReportError>,
12 pub expiration_date: Option<stripe_misc::GelatoDataDocumentReportExpirationDate>,
14 pub files: Option<Vec<String>>,
16 pub first_name: Option<String>,
18 pub issued_date: Option<stripe_misc::GelatoDataDocumentReportIssuedDate>,
20 pub issuing_country: Option<String>,
22 pub last_name: Option<String>,
24 pub number: Option<String>,
26 pub sex: Option<GelatoDocumentReportSex>,
28 pub status: GelatoDocumentReportStatus,
30 #[cfg_attr(any(feature = "deserialize", feature = "serialize"), serde(rename = "type"))]
32 pub type_: Option<GelatoDocumentReportType>,
33 pub unparsed_place_of_birth: Option<String>,
35 pub unparsed_sex: Option<String>,
37}
38#[doc(hidden)]
39pub struct GelatoDocumentReportBuilder {
40 address: Option<Option<stripe_shared::Address>>,
41 dob: Option<Option<stripe_misc::GelatoDataDocumentReportDateOfBirth>>,
42 error: Option<Option<stripe_misc::GelatoDocumentReportError>>,
43 expiration_date: Option<Option<stripe_misc::GelatoDataDocumentReportExpirationDate>>,
44 files: Option<Option<Vec<String>>>,
45 first_name: Option<Option<String>>,
46 issued_date: Option<Option<stripe_misc::GelatoDataDocumentReportIssuedDate>>,
47 issuing_country: Option<Option<String>>,
48 last_name: Option<Option<String>>,
49 number: Option<Option<String>>,
50 sex: Option<Option<GelatoDocumentReportSex>>,
51 status: Option<GelatoDocumentReportStatus>,
52 type_: Option<Option<GelatoDocumentReportType>>,
53 unparsed_place_of_birth: Option<Option<String>>,
54 unparsed_sex: Option<Option<String>>,
55}
56
57#[allow(
58 unused_variables,
59 irrefutable_let_patterns,
60 clippy::let_unit_value,
61 clippy::match_single_binding,
62 clippy::single_match
63)]
64const _: () = {
65 use miniserde::de::{Map, Visitor};
66 use miniserde::json::Value;
67 use miniserde::{Deserialize, Result, make_place};
68 use stripe_types::miniserde_helpers::FromValueOpt;
69 use stripe_types::{MapBuilder, ObjectDeser};
70
71 make_place!(Place);
72
73 impl Deserialize for GelatoDocumentReport {
74 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
75 Place::new(out)
76 }
77 }
78
79 struct Builder<'a> {
80 out: &'a mut Option<GelatoDocumentReport>,
81 builder: GelatoDocumentReportBuilder,
82 }
83
84 impl Visitor for Place<GelatoDocumentReport> {
85 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
86 Ok(Box::new(Builder {
87 out: &mut self.out,
88 builder: GelatoDocumentReportBuilder::deser_default(),
89 }))
90 }
91 }
92
93 impl MapBuilder for GelatoDocumentReportBuilder {
94 type Out = GelatoDocumentReport;
95 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
96 Ok(match k {
97 "address" => Deserialize::begin(&mut self.address),
98 "dob" => Deserialize::begin(&mut self.dob),
99 "error" => Deserialize::begin(&mut self.error),
100 "expiration_date" => Deserialize::begin(&mut self.expiration_date),
101 "files" => Deserialize::begin(&mut self.files),
102 "first_name" => Deserialize::begin(&mut self.first_name),
103 "issued_date" => Deserialize::begin(&mut self.issued_date),
104 "issuing_country" => Deserialize::begin(&mut self.issuing_country),
105 "last_name" => Deserialize::begin(&mut self.last_name),
106 "number" => Deserialize::begin(&mut self.number),
107 "sex" => Deserialize::begin(&mut self.sex),
108 "status" => Deserialize::begin(&mut self.status),
109 "type" => Deserialize::begin(&mut self.type_),
110 "unparsed_place_of_birth" => Deserialize::begin(&mut self.unparsed_place_of_birth),
111 "unparsed_sex" => Deserialize::begin(&mut self.unparsed_sex),
112 _ => <dyn Visitor>::ignore(),
113 })
114 }
115
116 fn deser_default() -> Self {
117 Self {
118 address: Deserialize::default(),
119 dob: Deserialize::default(),
120 error: Deserialize::default(),
121 expiration_date: Deserialize::default(),
122 files: Deserialize::default(),
123 first_name: Deserialize::default(),
124 issued_date: Deserialize::default(),
125 issuing_country: Deserialize::default(),
126 last_name: Deserialize::default(),
127 number: Deserialize::default(),
128 sex: Deserialize::default(),
129 status: Deserialize::default(),
130 type_: Deserialize::default(),
131 unparsed_place_of_birth: Deserialize::default(),
132 unparsed_sex: Deserialize::default(),
133 }
134 }
135
136 fn take_out(&mut self) -> Option<Self::Out> {
137 let (
138 Some(address),
139 Some(dob),
140 Some(error),
141 Some(expiration_date),
142 Some(files),
143 Some(first_name),
144 Some(issued_date),
145 Some(issuing_country),
146 Some(last_name),
147 Some(number),
148 Some(sex),
149 Some(status),
150 Some(type_),
151 Some(unparsed_place_of_birth),
152 Some(unparsed_sex),
153 ) = (
154 self.address.take(),
155 self.dob,
156 self.error.take(),
157 self.expiration_date,
158 self.files.take(),
159 self.first_name.take(),
160 self.issued_date,
161 self.issuing_country.take(),
162 self.last_name.take(),
163 self.number.take(),
164 self.sex.take(),
165 self.status.take(),
166 self.type_.take(),
167 self.unparsed_place_of_birth.take(),
168 self.unparsed_sex.take(),
169 )
170 else {
171 return None;
172 };
173 Some(Self::Out {
174 address,
175 dob,
176 error,
177 expiration_date,
178 files,
179 first_name,
180 issued_date,
181 issuing_country,
182 last_name,
183 number,
184 sex,
185 status,
186 type_,
187 unparsed_place_of_birth,
188 unparsed_sex,
189 })
190 }
191 }
192
193 impl Map for Builder<'_> {
194 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
195 self.builder.key(k)
196 }
197
198 fn finish(&mut self) -> Result<()> {
199 *self.out = self.builder.take_out();
200 Ok(())
201 }
202 }
203
204 impl ObjectDeser for GelatoDocumentReport {
205 type Builder = GelatoDocumentReportBuilder;
206 }
207
208 impl FromValueOpt for GelatoDocumentReport {
209 fn from_value(v: Value) -> Option<Self> {
210 let Value::Object(obj) = v else {
211 return None;
212 };
213 let mut b = GelatoDocumentReportBuilder::deser_default();
214 for (k, v) in obj {
215 match k.as_str() {
216 "address" => b.address = FromValueOpt::from_value(v),
217 "dob" => b.dob = FromValueOpt::from_value(v),
218 "error" => b.error = FromValueOpt::from_value(v),
219 "expiration_date" => b.expiration_date = FromValueOpt::from_value(v),
220 "files" => b.files = FromValueOpt::from_value(v),
221 "first_name" => b.first_name = FromValueOpt::from_value(v),
222 "issued_date" => b.issued_date = FromValueOpt::from_value(v),
223 "issuing_country" => b.issuing_country = FromValueOpt::from_value(v),
224 "last_name" => b.last_name = FromValueOpt::from_value(v),
225 "number" => b.number = FromValueOpt::from_value(v),
226 "sex" => b.sex = FromValueOpt::from_value(v),
227 "status" => b.status = FromValueOpt::from_value(v),
228 "type" => b.type_ = FromValueOpt::from_value(v),
229 "unparsed_place_of_birth" => {
230 b.unparsed_place_of_birth = FromValueOpt::from_value(v)
231 }
232 "unparsed_sex" => b.unparsed_sex = FromValueOpt::from_value(v),
233 _ => {}
234 }
235 }
236 b.take_out()
237 }
238 }
239};
240#[derive(Clone, Eq, PartialEq)]
242#[non_exhaustive]
243pub enum GelatoDocumentReportSex {
244 Redacted,
245 Female,
246 Male,
247 Unknown,
248 _Unknown(String),
251}
252impl GelatoDocumentReportSex {
253 pub fn as_str(&self) -> &str {
254 use GelatoDocumentReportSex::*;
255 match self {
256 Redacted => "[redacted]",
257 Female => "female",
258 Male => "male",
259 Unknown => "unknown",
260 _Unknown(v) => v,
261 }
262 }
263}
264
265impl std::str::FromStr for GelatoDocumentReportSex {
266 type Err = std::convert::Infallible;
267 fn from_str(s: &str) -> Result<Self, Self::Err> {
268 use GelatoDocumentReportSex::*;
269 match s {
270 "[redacted]" => Ok(Redacted),
271 "female" => Ok(Female),
272 "male" => Ok(Male),
273 "unknown" => Ok(Unknown),
274 v => {
275 tracing::warn!("Unknown value '{}' for enum '{}'", v, "GelatoDocumentReportSex");
276 Ok(_Unknown(v.to_owned()))
277 }
278 }
279 }
280}
281impl std::fmt::Display for GelatoDocumentReportSex {
282 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
283 f.write_str(self.as_str())
284 }
285}
286
287impl std::fmt::Debug for GelatoDocumentReportSex {
288 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
289 f.write_str(self.as_str())
290 }
291}
292#[cfg(feature = "serialize")]
293impl serde::Serialize for GelatoDocumentReportSex {
294 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
295 where
296 S: serde::Serializer,
297 {
298 serializer.serialize_str(self.as_str())
299 }
300}
301impl miniserde::Deserialize for GelatoDocumentReportSex {
302 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
303 crate::Place::new(out)
304 }
305}
306
307impl miniserde::de::Visitor for crate::Place<GelatoDocumentReportSex> {
308 fn string(&mut self, s: &str) -> miniserde::Result<()> {
309 use std::str::FromStr;
310 self.out = Some(GelatoDocumentReportSex::from_str(s).expect("infallible"));
311 Ok(())
312 }
313}
314
315stripe_types::impl_from_val_with_from_str!(GelatoDocumentReportSex);
316#[cfg(feature = "deserialize")]
317impl<'de> serde::Deserialize<'de> for GelatoDocumentReportSex {
318 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
319 use std::str::FromStr;
320 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
321 Ok(Self::from_str(&s).expect("infallible"))
322 }
323}
324#[derive(Clone, Eq, PartialEq)]
326#[non_exhaustive]
327pub enum GelatoDocumentReportStatus {
328 Unverified,
329 Verified,
330 Unknown(String),
332}
333impl GelatoDocumentReportStatus {
334 pub fn as_str(&self) -> &str {
335 use GelatoDocumentReportStatus::*;
336 match self {
337 Unverified => "unverified",
338 Verified => "verified",
339 Unknown(v) => v,
340 }
341 }
342}
343
344impl std::str::FromStr for GelatoDocumentReportStatus {
345 type Err = std::convert::Infallible;
346 fn from_str(s: &str) -> Result<Self, Self::Err> {
347 use GelatoDocumentReportStatus::*;
348 match s {
349 "unverified" => Ok(Unverified),
350 "verified" => Ok(Verified),
351 v => {
352 tracing::warn!("Unknown value '{}' for enum '{}'", v, "GelatoDocumentReportStatus");
353 Ok(Unknown(v.to_owned()))
354 }
355 }
356 }
357}
358impl std::fmt::Display for GelatoDocumentReportStatus {
359 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
360 f.write_str(self.as_str())
361 }
362}
363
364impl std::fmt::Debug for GelatoDocumentReportStatus {
365 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
366 f.write_str(self.as_str())
367 }
368}
369#[cfg(feature = "serialize")]
370impl serde::Serialize for GelatoDocumentReportStatus {
371 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
372 where
373 S: serde::Serializer,
374 {
375 serializer.serialize_str(self.as_str())
376 }
377}
378impl miniserde::Deserialize for GelatoDocumentReportStatus {
379 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
380 crate::Place::new(out)
381 }
382}
383
384impl miniserde::de::Visitor for crate::Place<GelatoDocumentReportStatus> {
385 fn string(&mut self, s: &str) -> miniserde::Result<()> {
386 use std::str::FromStr;
387 self.out = Some(GelatoDocumentReportStatus::from_str(s).expect("infallible"));
388 Ok(())
389 }
390}
391
392stripe_types::impl_from_val_with_from_str!(GelatoDocumentReportStatus);
393#[cfg(feature = "deserialize")]
394impl<'de> serde::Deserialize<'de> for GelatoDocumentReportStatus {
395 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
396 use std::str::FromStr;
397 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
398 Ok(Self::from_str(&s).expect("infallible"))
399 }
400}
401#[derive(Clone, Eq, PartialEq)]
403#[non_exhaustive]
404pub enum GelatoDocumentReportType {
405 DrivingLicense,
406 IdCard,
407 Passport,
408 Unknown(String),
410}
411impl GelatoDocumentReportType {
412 pub fn as_str(&self) -> &str {
413 use GelatoDocumentReportType::*;
414 match self {
415 DrivingLicense => "driving_license",
416 IdCard => "id_card",
417 Passport => "passport",
418 Unknown(v) => v,
419 }
420 }
421}
422
423impl std::str::FromStr for GelatoDocumentReportType {
424 type Err = std::convert::Infallible;
425 fn from_str(s: &str) -> Result<Self, Self::Err> {
426 use GelatoDocumentReportType::*;
427 match s {
428 "driving_license" => Ok(DrivingLicense),
429 "id_card" => Ok(IdCard),
430 "passport" => Ok(Passport),
431 v => {
432 tracing::warn!("Unknown value '{}' for enum '{}'", v, "GelatoDocumentReportType");
433 Ok(Unknown(v.to_owned()))
434 }
435 }
436 }
437}
438impl std::fmt::Display for GelatoDocumentReportType {
439 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
440 f.write_str(self.as_str())
441 }
442}
443
444impl std::fmt::Debug for GelatoDocumentReportType {
445 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
446 f.write_str(self.as_str())
447 }
448}
449#[cfg(feature = "serialize")]
450impl serde::Serialize for GelatoDocumentReportType {
451 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
452 where
453 S: serde::Serializer,
454 {
455 serializer.serialize_str(self.as_str())
456 }
457}
458impl miniserde::Deserialize for GelatoDocumentReportType {
459 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
460 crate::Place::new(out)
461 }
462}
463
464impl miniserde::de::Visitor for crate::Place<GelatoDocumentReportType> {
465 fn string(&mut self, s: &str) -> miniserde::Result<()> {
466 use std::str::FromStr;
467 self.out = Some(GelatoDocumentReportType::from_str(s).expect("infallible"));
468 Ok(())
469 }
470}
471
472stripe_types::impl_from_val_with_from_str!(GelatoDocumentReportType);
473#[cfg(feature = "deserialize")]
474impl<'de> serde::Deserialize<'de> for GelatoDocumentReportType {
475 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
476 use std::str::FromStr;
477 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
478 Ok(Self::from_str(&s).expect("infallible"))
479 }
480}