1#[derive(Clone, Eq, PartialEq)]
3#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
4#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
5#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
6pub struct GelatoSessionLastError {
7 pub code: Option<GelatoSessionLastErrorCode>,
9 pub reason: Option<String>,
11}
12#[cfg(feature = "redact-generated-debug")]
13impl std::fmt::Debug for GelatoSessionLastError {
14 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
15 f.debug_struct("GelatoSessionLastError").finish_non_exhaustive()
16 }
17}
18#[doc(hidden)]
19pub struct GelatoSessionLastErrorBuilder {
20 code: Option<Option<GelatoSessionLastErrorCode>>,
21 reason: Option<Option<String>>,
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 GelatoSessionLastError {
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<GelatoSessionLastError>,
48 builder: GelatoSessionLastErrorBuilder,
49 }
50
51 impl Visitor for Place<GelatoSessionLastError> {
52 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
53 Ok(Box::new(Builder {
54 out: &mut self.out,
55 builder: GelatoSessionLastErrorBuilder::deser_default(),
56 }))
57 }
58 }
59
60 impl MapBuilder for GelatoSessionLastErrorBuilder {
61 type Out = GelatoSessionLastError;
62 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
63 Ok(match k {
64 "code" => Deserialize::begin(&mut self.code),
65 "reason" => Deserialize::begin(&mut self.reason),
66 _ => <dyn Visitor>::ignore(),
67 })
68 }
69
70 fn deser_default() -> Self {
71 Self { code: Some(None), reason: Some(None) }
72 }
73
74 fn take_out(&mut self) -> Option<Self::Out> {
75 let (Some(code), Some(reason)) = (self.code.take(), self.reason.take()) else {
76 return None;
77 };
78 Some(Self::Out { code, reason })
79 }
80 }
81
82 impl Map for Builder<'_> {
83 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
84 self.builder.key(k)
85 }
86
87 fn finish(&mut self) -> Result<()> {
88 *self.out = self.builder.take_out();
89 Ok(())
90 }
91 }
92
93 impl ObjectDeser for GelatoSessionLastError {
94 type Builder = GelatoSessionLastErrorBuilder;
95 }
96
97 impl FromValueOpt for GelatoSessionLastError {
98 fn from_value(v: Value) -> Option<Self> {
99 let Value::Object(obj) = v else {
100 return None;
101 };
102 let mut b = GelatoSessionLastErrorBuilder::deser_default();
103 for (k, v) in obj {
104 match k.as_str() {
105 "code" => b.code = FromValueOpt::from_value(v),
106 "reason" => b.reason = FromValueOpt::from_value(v),
107 _ => {}
108 }
109 }
110 b.take_out()
111 }
112 }
113};
114#[derive(Clone, Eq, PartialEq)]
116#[non_exhaustive]
117pub enum GelatoSessionLastErrorCode {
118 Abandoned,
119 ConsentDeclined,
120 CountryNotSupported,
121 DeviceNotSupported,
122 DocumentExpired,
123 DocumentTypeNotSupported,
124 DocumentUnverifiedOther,
125 EmailUnverifiedOther,
126 EmailVerificationDeclined,
127 IdNumberInsufficientDocumentData,
128 IdNumberMismatch,
129 IdNumberUnverifiedOther,
130 PhoneUnverifiedOther,
131 PhoneVerificationDeclined,
132 SelfieDocumentMissingPhoto,
133 SelfieFaceMismatch,
134 SelfieManipulated,
135 SelfieUnverifiedOther,
136 UnderSupportedAge,
137 Unknown(String),
139}
140impl GelatoSessionLastErrorCode {
141 pub fn as_str(&self) -> &str {
142 use GelatoSessionLastErrorCode::*;
143 match self {
144 Abandoned => "abandoned",
145 ConsentDeclined => "consent_declined",
146 CountryNotSupported => "country_not_supported",
147 DeviceNotSupported => "device_not_supported",
148 DocumentExpired => "document_expired",
149 DocumentTypeNotSupported => "document_type_not_supported",
150 DocumentUnverifiedOther => "document_unverified_other",
151 EmailUnverifiedOther => "email_unverified_other",
152 EmailVerificationDeclined => "email_verification_declined",
153 IdNumberInsufficientDocumentData => "id_number_insufficient_document_data",
154 IdNumberMismatch => "id_number_mismatch",
155 IdNumberUnverifiedOther => "id_number_unverified_other",
156 PhoneUnverifiedOther => "phone_unverified_other",
157 PhoneVerificationDeclined => "phone_verification_declined",
158 SelfieDocumentMissingPhoto => "selfie_document_missing_photo",
159 SelfieFaceMismatch => "selfie_face_mismatch",
160 SelfieManipulated => "selfie_manipulated",
161 SelfieUnverifiedOther => "selfie_unverified_other",
162 UnderSupportedAge => "under_supported_age",
163 Unknown(v) => v,
164 }
165 }
166}
167
168impl std::str::FromStr for GelatoSessionLastErrorCode {
169 type Err = std::convert::Infallible;
170 fn from_str(s: &str) -> Result<Self, Self::Err> {
171 use GelatoSessionLastErrorCode::*;
172 match s {
173 "abandoned" => Ok(Abandoned),
174 "consent_declined" => Ok(ConsentDeclined),
175 "country_not_supported" => Ok(CountryNotSupported),
176 "device_not_supported" => Ok(DeviceNotSupported),
177 "document_expired" => Ok(DocumentExpired),
178 "document_type_not_supported" => Ok(DocumentTypeNotSupported),
179 "document_unverified_other" => Ok(DocumentUnverifiedOther),
180 "email_unverified_other" => Ok(EmailUnverifiedOther),
181 "email_verification_declined" => Ok(EmailVerificationDeclined),
182 "id_number_insufficient_document_data" => Ok(IdNumberInsufficientDocumentData),
183 "id_number_mismatch" => Ok(IdNumberMismatch),
184 "id_number_unverified_other" => Ok(IdNumberUnverifiedOther),
185 "phone_unverified_other" => Ok(PhoneUnverifiedOther),
186 "phone_verification_declined" => Ok(PhoneVerificationDeclined),
187 "selfie_document_missing_photo" => Ok(SelfieDocumentMissingPhoto),
188 "selfie_face_mismatch" => Ok(SelfieFaceMismatch),
189 "selfie_manipulated" => Ok(SelfieManipulated),
190 "selfie_unverified_other" => Ok(SelfieUnverifiedOther),
191 "under_supported_age" => Ok(UnderSupportedAge),
192 v => {
193 tracing::warn!("Unknown value '{}' for enum '{}'", v, "GelatoSessionLastErrorCode");
194 Ok(Unknown(v.to_owned()))
195 }
196 }
197 }
198}
199impl std::fmt::Display for GelatoSessionLastErrorCode {
200 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
201 f.write_str(self.as_str())
202 }
203}
204
205#[cfg(not(feature = "redact-generated-debug"))]
206impl std::fmt::Debug for GelatoSessionLastErrorCode {
207 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
208 f.write_str(self.as_str())
209 }
210}
211#[cfg(feature = "redact-generated-debug")]
212impl std::fmt::Debug for GelatoSessionLastErrorCode {
213 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
214 f.debug_struct(stringify!(GelatoSessionLastErrorCode)).finish_non_exhaustive()
215 }
216}
217#[cfg(feature = "serialize")]
218impl serde::Serialize for GelatoSessionLastErrorCode {
219 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
220 where
221 S: serde::Serializer,
222 {
223 serializer.serialize_str(self.as_str())
224 }
225}
226impl miniserde::Deserialize for GelatoSessionLastErrorCode {
227 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
228 crate::Place::new(out)
229 }
230}
231
232impl miniserde::de::Visitor for crate::Place<GelatoSessionLastErrorCode> {
233 fn string(&mut self, s: &str) -> miniserde::Result<()> {
234 use std::str::FromStr;
235 self.out = Some(GelatoSessionLastErrorCode::from_str(s).expect("infallible"));
236 Ok(())
237 }
238}
239
240stripe_types::impl_from_val_with_from_str!(GelatoSessionLastErrorCode);
241#[cfg(feature = "deserialize")]
242impl<'de> serde::Deserialize<'de> for GelatoSessionLastErrorCode {
243 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
244 use std::str::FromStr;
245 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
246 Ok(Self::from_str(&s).expect("infallible"))
247 }
248}