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::{make_place, Deserialize, Result};
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
103 _ => <dyn Visitor>::ignore(),
104 })
105 }
106
107 fn deser_default() -> Self {
108 Self {
109 account_type: Deserialize::default(),
110 application_cryptogram: Deserialize::default(),
111 application_preferred_name: Deserialize::default(),
112 authorization_code: Deserialize::default(),
113 authorization_response_code: Deserialize::default(),
114 cardholder_verification_method: Deserialize::default(),
115 dedicated_file_name: Deserialize::default(),
116 terminal_verification_results: Deserialize::default(),
117 transaction_status_information: Deserialize::default(),
118 }
119 }
120
121 fn take_out(&mut self) -> Option<Self::Out> {
122 let (
123 Some(account_type),
124 Some(application_cryptogram),
125 Some(application_preferred_name),
126 Some(authorization_code),
127 Some(authorization_response_code),
128 Some(cardholder_verification_method),
129 Some(dedicated_file_name),
130 Some(terminal_verification_results),
131 Some(transaction_status_information),
132 ) = (
133 self.account_type,
134 self.application_cryptogram.take(),
135 self.application_preferred_name.take(),
136 self.authorization_code.take(),
137 self.authorization_response_code.take(),
138 self.cardholder_verification_method.take(),
139 self.dedicated_file_name.take(),
140 self.terminal_verification_results.take(),
141 self.transaction_status_information.take(),
142 )
143 else {
144 return None;
145 };
146 Some(Self::Out {
147 account_type,
148 application_cryptogram,
149 application_preferred_name,
150 authorization_code,
151 authorization_response_code,
152 cardholder_verification_method,
153 dedicated_file_name,
154 terminal_verification_results,
155 transaction_status_information,
156 })
157 }
158 }
159
160 impl Map for Builder<'_> {
161 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
162 self.builder.key(k)
163 }
164
165 fn finish(&mut self) -> Result<()> {
166 *self.out = self.builder.take_out();
167 Ok(())
168 }
169 }
170
171 impl ObjectDeser for PaymentMethodDetailsInteracPresentReceipt {
172 type Builder = PaymentMethodDetailsInteracPresentReceiptBuilder;
173 }
174
175 impl FromValueOpt for PaymentMethodDetailsInteracPresentReceipt {
176 fn from_value(v: Value) -> Option<Self> {
177 let Value::Object(obj) = v else {
178 return None;
179 };
180 let mut b = PaymentMethodDetailsInteracPresentReceiptBuilder::deser_default();
181 for (k, v) in obj {
182 match k.as_str() {
183 "account_type" => b.account_type = FromValueOpt::from_value(v),
184 "application_cryptogram" => {
185 b.application_cryptogram = FromValueOpt::from_value(v)
186 }
187 "application_preferred_name" => {
188 b.application_preferred_name = FromValueOpt::from_value(v)
189 }
190 "authorization_code" => b.authorization_code = FromValueOpt::from_value(v),
191 "authorization_response_code" => {
192 b.authorization_response_code = FromValueOpt::from_value(v)
193 }
194 "cardholder_verification_method" => {
195 b.cardholder_verification_method = FromValueOpt::from_value(v)
196 }
197 "dedicated_file_name" => b.dedicated_file_name = FromValueOpt::from_value(v),
198 "terminal_verification_results" => {
199 b.terminal_verification_results = FromValueOpt::from_value(v)
200 }
201 "transaction_status_information" => {
202 b.transaction_status_information = FromValueOpt::from_value(v)
203 }
204
205 _ => {}
206 }
207 }
208 b.take_out()
209 }
210 }
211};
212#[derive(Copy, Clone, Eq, PartialEq)]
214pub enum PaymentMethodDetailsInteracPresentReceiptAccountType {
215 Checking,
216 Savings,
217 Unknown,
218}
219impl PaymentMethodDetailsInteracPresentReceiptAccountType {
220 pub fn as_str(self) -> &'static str {
221 use PaymentMethodDetailsInteracPresentReceiptAccountType::*;
222 match self {
223 Checking => "checking",
224 Savings => "savings",
225 Unknown => "unknown",
226 }
227 }
228}
229
230impl std::str::FromStr for PaymentMethodDetailsInteracPresentReceiptAccountType {
231 type Err = stripe_types::StripeParseError;
232 fn from_str(s: &str) -> Result<Self, Self::Err> {
233 use PaymentMethodDetailsInteracPresentReceiptAccountType::*;
234 match s {
235 "checking" => Ok(Checking),
236 "savings" => Ok(Savings),
237 "unknown" => Ok(Unknown),
238 _ => Err(stripe_types::StripeParseError),
239 }
240 }
241}
242impl std::fmt::Display for PaymentMethodDetailsInteracPresentReceiptAccountType {
243 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
244 f.write_str(self.as_str())
245 }
246}
247
248impl std::fmt::Debug for PaymentMethodDetailsInteracPresentReceiptAccountType {
249 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
250 f.write_str(self.as_str())
251 }
252}
253#[cfg(feature = "serialize")]
254impl serde::Serialize for PaymentMethodDetailsInteracPresentReceiptAccountType {
255 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
256 where
257 S: serde::Serializer,
258 {
259 serializer.serialize_str(self.as_str())
260 }
261}
262impl miniserde::Deserialize for PaymentMethodDetailsInteracPresentReceiptAccountType {
263 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
264 crate::Place::new(out)
265 }
266}
267
268impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsInteracPresentReceiptAccountType> {
269 fn string(&mut self, s: &str) -> miniserde::Result<()> {
270 use std::str::FromStr;
271 self.out = Some(
272 PaymentMethodDetailsInteracPresentReceiptAccountType::from_str(s)
273 .map_err(|_| miniserde::Error)?,
274 );
275 Ok(())
276 }
277}
278
279stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsInteracPresentReceiptAccountType);
280#[cfg(feature = "deserialize")]
281impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsInteracPresentReceiptAccountType {
282 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
283 use std::str::FromStr;
284 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
285 Self::from_str(&s).map_err(|_| {
286 serde::de::Error::custom(
287 "Unknown value for PaymentMethodDetailsInteracPresentReceiptAccountType",
288 )
289 })
290 }
291}