stripe_shared/
legal_entity_person_verification_document.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct LegalEntityPersonVerificationDocument {
5    /// The back of an ID returned by a [file upload](https://stripe.com/docs/api#create_file) with a `purpose` value of `identity_document`.
6    pub back: Option<stripe_types::Expandable<stripe_shared::File>>,
7    /// A user-displayable string describing the verification state of this document.
8    /// For example, if a document is uploaded and the picture is too fuzzy, this may say "Identity document is too unclear to read".
9    pub details: Option<String>,
10    /// One of `document_corrupt`, `document_country_not_supported`, `document_expired`, `document_failed_copy`, `document_failed_other`, `document_failed_test_mode`, `document_fraudulent`, `document_failed_greyscale`, `document_incomplete`, `document_invalid`, `document_manipulated`, `document_missing_back`, `document_missing_front`, `document_not_readable`, `document_not_uploaded`, `document_photo_mismatch`, `document_too_large`, or `document_type_not_supported`.
11    /// A machine-readable code specifying the verification state for this document.
12    pub details_code: Option<String>,
13    /// The front of an ID returned by a [file upload](https://stripe.com/docs/api#create_file) with a `purpose` value of `identity_document`.
14    pub front: Option<stripe_types::Expandable<stripe_shared::File>>,
15}
16#[doc(hidden)]
17pub struct LegalEntityPersonVerificationDocumentBuilder {
18    back: Option<Option<stripe_types::Expandable<stripe_shared::File>>>,
19    details: Option<Option<String>>,
20    details_code: Option<Option<String>>,
21    front: Option<Option<stripe_types::Expandable<stripe_shared::File>>>,
22}
23
24#[allow(
25    unused_variables,
26    irrefutable_let_patterns,
27    clippy::let_unit_value,
28    clippy::match_single_binding,
29    clippy::single_match
30)]
31const _: () = {
32    use miniserde::de::{Map, Visitor};
33    use miniserde::json::Value;
34    use miniserde::{Deserialize, Result, make_place};
35    use stripe_types::miniserde_helpers::FromValueOpt;
36    use stripe_types::{MapBuilder, ObjectDeser};
37
38    make_place!(Place);
39
40    impl Deserialize for LegalEntityPersonVerificationDocument {
41        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
42            Place::new(out)
43        }
44    }
45
46    struct Builder<'a> {
47        out: &'a mut Option<LegalEntityPersonVerificationDocument>,
48        builder: LegalEntityPersonVerificationDocumentBuilder,
49    }
50
51    impl Visitor for Place<LegalEntityPersonVerificationDocument> {
52        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
53            Ok(Box::new(Builder {
54                out: &mut self.out,
55                builder: LegalEntityPersonVerificationDocumentBuilder::deser_default(),
56            }))
57        }
58    }
59
60    impl MapBuilder for LegalEntityPersonVerificationDocumentBuilder {
61        type Out = LegalEntityPersonVerificationDocument;
62        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
63            Ok(match k {
64                "back" => Deserialize::begin(&mut self.back),
65                "details" => Deserialize::begin(&mut self.details),
66                "details_code" => Deserialize::begin(&mut self.details_code),
67                "front" => Deserialize::begin(&mut self.front),
68                _ => <dyn Visitor>::ignore(),
69            })
70        }
71
72        fn deser_default() -> Self {
73            Self {
74                back: Deserialize::default(),
75                details: Deserialize::default(),
76                details_code: Deserialize::default(),
77                front: Deserialize::default(),
78            }
79        }
80
81        fn take_out(&mut self) -> Option<Self::Out> {
82            let (Some(back), Some(details), Some(details_code), Some(front)) = (
83                self.back.take(),
84                self.details.take(),
85                self.details_code.take(),
86                self.front.take(),
87            ) else {
88                return None;
89            };
90            Some(Self::Out { back, details, details_code, front })
91        }
92    }
93
94    impl Map for Builder<'_> {
95        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
96            self.builder.key(k)
97        }
98
99        fn finish(&mut self) -> Result<()> {
100            *self.out = self.builder.take_out();
101            Ok(())
102        }
103    }
104
105    impl ObjectDeser for LegalEntityPersonVerificationDocument {
106        type Builder = LegalEntityPersonVerificationDocumentBuilder;
107    }
108
109    impl FromValueOpt for LegalEntityPersonVerificationDocument {
110        fn from_value(v: Value) -> Option<Self> {
111            let Value::Object(obj) = v else {
112                return None;
113            };
114            let mut b = LegalEntityPersonVerificationDocumentBuilder::deser_default();
115            for (k, v) in obj {
116                match k.as_str() {
117                    "back" => b.back = FromValueOpt::from_value(v),
118                    "details" => b.details = FromValueOpt::from_value(v),
119                    "details_code" => b.details_code = FromValueOpt::from_value(v),
120                    "front" => b.front = FromValueOpt::from_value(v),
121                    _ => {}
122                }
123            }
124            b.take_out()
125        }
126    }
127};