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