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