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