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 PaymentMethodDetailsCardPresentReceipt {
6 pub account_type: Option<PaymentMethodDetailsCardPresentReceiptAccountType>,
8 pub application_cryptogram: Option<String>,
10 pub application_preferred_name: Option<String>,
13 pub authorization_code: Option<String>,
15 pub authorization_response_code: Option<String>,
17 pub cardholder_verification_method: Option<String>,
20 pub dedicated_file_name: Option<String>,
23 pub terminal_verification_results: Option<String>,
27 pub transaction_status_information: Option<String>,
30}
31#[cfg(feature = "redact-generated-debug")]
32impl std::fmt::Debug for PaymentMethodDetailsCardPresentReceipt {
33 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
34 f.debug_struct("PaymentMethodDetailsCardPresentReceipt").finish_non_exhaustive()
35 }
36}
37#[doc(hidden)]
38pub struct PaymentMethodDetailsCardPresentReceiptBuilder {
39 account_type: Option<Option<PaymentMethodDetailsCardPresentReceiptAccountType>>,
40 application_cryptogram: Option<Option<String>>,
41 application_preferred_name: Option<Option<String>>,
42 authorization_code: Option<Option<String>>,
43 authorization_response_code: Option<Option<String>>,
44 cardholder_verification_method: Option<Option<String>>,
45 dedicated_file_name: Option<Option<String>>,
46 terminal_verification_results: Option<Option<String>>,
47 transaction_status_information: Option<Option<String>>,
48}
49
50#[allow(
51 unused_variables,
52 irrefutable_let_patterns,
53 clippy::let_unit_value,
54 clippy::match_single_binding,
55 clippy::single_match
56)]
57const _: () = {
58 use miniserde::de::{Map, Visitor};
59 use miniserde::json::Value;
60 use miniserde::{Deserialize, Result, make_place};
61 use stripe_types::miniserde_helpers::FromValueOpt;
62 use stripe_types::{MapBuilder, ObjectDeser};
63
64 make_place!(Place);
65
66 impl Deserialize for PaymentMethodDetailsCardPresentReceipt {
67 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
68 Place::new(out)
69 }
70 }
71
72 struct Builder<'a> {
73 out: &'a mut Option<PaymentMethodDetailsCardPresentReceipt>,
74 builder: PaymentMethodDetailsCardPresentReceiptBuilder,
75 }
76
77 impl Visitor for Place<PaymentMethodDetailsCardPresentReceipt> {
78 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
79 Ok(Box::new(Builder {
80 out: &mut self.out,
81 builder: PaymentMethodDetailsCardPresentReceiptBuilder::deser_default(),
82 }))
83 }
84 }
85
86 impl MapBuilder for PaymentMethodDetailsCardPresentReceiptBuilder {
87 type Out = PaymentMethodDetailsCardPresentReceipt;
88 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
89 Ok(match k {
90 "account_type" => Deserialize::begin(&mut self.account_type),
91 "application_cryptogram" => Deserialize::begin(&mut self.application_cryptogram),
92 "application_preferred_name" => {
93 Deserialize::begin(&mut self.application_preferred_name)
94 }
95 "authorization_code" => Deserialize::begin(&mut self.authorization_code),
96 "authorization_response_code" => {
97 Deserialize::begin(&mut self.authorization_response_code)
98 }
99 "cardholder_verification_method" => {
100 Deserialize::begin(&mut self.cardholder_verification_method)
101 }
102 "dedicated_file_name" => Deserialize::begin(&mut self.dedicated_file_name),
103 "terminal_verification_results" => {
104 Deserialize::begin(&mut self.terminal_verification_results)
105 }
106 "transaction_status_information" => {
107 Deserialize::begin(&mut self.transaction_status_information)
108 }
109 _ => <dyn Visitor>::ignore(),
110 })
111 }
112
113 fn deser_default() -> Self {
114 Self {
115 account_type: Some(None),
116 application_cryptogram: Some(None),
117 application_preferred_name: Some(None),
118 authorization_code: Some(None),
119 authorization_response_code: Some(None),
120 cardholder_verification_method: Some(None),
121 dedicated_file_name: Some(None),
122 terminal_verification_results: Some(None),
123 transaction_status_information: Some(None),
124 }
125 }
126
127 fn take_out(&mut self) -> Option<Self::Out> {
128 let (
129 Some(account_type),
130 Some(application_cryptogram),
131 Some(application_preferred_name),
132 Some(authorization_code),
133 Some(authorization_response_code),
134 Some(cardholder_verification_method),
135 Some(dedicated_file_name),
136 Some(terminal_verification_results),
137 Some(transaction_status_information),
138 ) = (
139 self.account_type.take(),
140 self.application_cryptogram.take(),
141 self.application_preferred_name.take(),
142 self.authorization_code.take(),
143 self.authorization_response_code.take(),
144 self.cardholder_verification_method.take(),
145 self.dedicated_file_name.take(),
146 self.terminal_verification_results.take(),
147 self.transaction_status_information.take(),
148 )
149 else {
150 return None;
151 };
152 Some(Self::Out {
153 account_type,
154 application_cryptogram,
155 application_preferred_name,
156 authorization_code,
157 authorization_response_code,
158 cardholder_verification_method,
159 dedicated_file_name,
160 terminal_verification_results,
161 transaction_status_information,
162 })
163 }
164 }
165
166 impl Map for Builder<'_> {
167 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
168 self.builder.key(k)
169 }
170
171 fn finish(&mut self) -> Result<()> {
172 *self.out = self.builder.take_out();
173 Ok(())
174 }
175 }
176
177 impl ObjectDeser for PaymentMethodDetailsCardPresentReceipt {
178 type Builder = PaymentMethodDetailsCardPresentReceiptBuilder;
179 }
180
181 impl FromValueOpt for PaymentMethodDetailsCardPresentReceipt {
182 fn from_value(v: Value) -> Option<Self> {
183 let Value::Object(obj) = v else {
184 return None;
185 };
186 let mut b = PaymentMethodDetailsCardPresentReceiptBuilder::deser_default();
187 for (k, v) in obj {
188 match k.as_str() {
189 "account_type" => b.account_type = FromValueOpt::from_value(v),
190 "application_cryptogram" => {
191 b.application_cryptogram = FromValueOpt::from_value(v)
192 }
193 "application_preferred_name" => {
194 b.application_preferred_name = FromValueOpt::from_value(v)
195 }
196 "authorization_code" => b.authorization_code = FromValueOpt::from_value(v),
197 "authorization_response_code" => {
198 b.authorization_response_code = FromValueOpt::from_value(v)
199 }
200 "cardholder_verification_method" => {
201 b.cardholder_verification_method = FromValueOpt::from_value(v)
202 }
203 "dedicated_file_name" => b.dedicated_file_name = FromValueOpt::from_value(v),
204 "terminal_verification_results" => {
205 b.terminal_verification_results = FromValueOpt::from_value(v)
206 }
207 "transaction_status_information" => {
208 b.transaction_status_information = FromValueOpt::from_value(v)
209 }
210 _ => {}
211 }
212 }
213 b.take_out()
214 }
215 }
216};
217#[derive(Clone, Eq, PartialEq)]
219#[non_exhaustive]
220pub enum PaymentMethodDetailsCardPresentReceiptAccountType {
221 Checking,
222 Credit,
223 Prepaid,
224 Unknown,
225 _Unknown(String),
228}
229impl PaymentMethodDetailsCardPresentReceiptAccountType {
230 pub fn as_str(&self) -> &str {
231 use PaymentMethodDetailsCardPresentReceiptAccountType::*;
232 match self {
233 Checking => "checking",
234 Credit => "credit",
235 Prepaid => "prepaid",
236 Unknown => "unknown",
237 _Unknown(v) => v,
238 }
239 }
240}
241
242impl std::str::FromStr for PaymentMethodDetailsCardPresentReceiptAccountType {
243 type Err = std::convert::Infallible;
244 fn from_str(s: &str) -> Result<Self, Self::Err> {
245 use PaymentMethodDetailsCardPresentReceiptAccountType::*;
246 match s {
247 "checking" => Ok(Checking),
248 "credit" => Ok(Credit),
249 "prepaid" => Ok(Prepaid),
250 "unknown" => Ok(Unknown),
251 v => {
252 tracing::warn!(
253 "Unknown value '{}' for enum '{}'",
254 v,
255 "PaymentMethodDetailsCardPresentReceiptAccountType"
256 );
257 Ok(_Unknown(v.to_owned()))
258 }
259 }
260 }
261}
262impl std::fmt::Display for PaymentMethodDetailsCardPresentReceiptAccountType {
263 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
264 f.write_str(self.as_str())
265 }
266}
267
268#[cfg(not(feature = "redact-generated-debug"))]
269impl std::fmt::Debug for PaymentMethodDetailsCardPresentReceiptAccountType {
270 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
271 f.write_str(self.as_str())
272 }
273}
274#[cfg(feature = "redact-generated-debug")]
275impl std::fmt::Debug for PaymentMethodDetailsCardPresentReceiptAccountType {
276 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
277 f.debug_struct(stringify!(PaymentMethodDetailsCardPresentReceiptAccountType))
278 .finish_non_exhaustive()
279 }
280}
281#[cfg(feature = "serialize")]
282impl serde::Serialize for PaymentMethodDetailsCardPresentReceiptAccountType {
283 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
284 where
285 S: serde::Serializer,
286 {
287 serializer.serialize_str(self.as_str())
288 }
289}
290impl miniserde::Deserialize for PaymentMethodDetailsCardPresentReceiptAccountType {
291 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
292 crate::Place::new(out)
293 }
294}
295
296impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsCardPresentReceiptAccountType> {
297 fn string(&mut self, s: &str) -> miniserde::Result<()> {
298 use std::str::FromStr;
299 self.out = Some(
300 PaymentMethodDetailsCardPresentReceiptAccountType::from_str(s).expect("infallible"),
301 );
302 Ok(())
303 }
304}
305
306stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsCardPresentReceiptAccountType);
307#[cfg(feature = "deserialize")]
308impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsCardPresentReceiptAccountType {
309 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
310 use std::str::FromStr;
311 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
312 Ok(Self::from_str(&s).expect("infallible"))
313 }
314}