1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct SetupIntentPaymentMethodOptionsCard {
5 pub mandate_options: Option<stripe_shared::SetupIntentPaymentMethodOptionsCardMandateOptions>,
7 pub network: Option<SetupIntentPaymentMethodOptionsCardNetwork>,
11 pub request_three_d_secure: Option<SetupIntentPaymentMethodOptionsCardRequestThreeDSecure>,
16}
17#[doc(hidden)]
18pub struct SetupIntentPaymentMethodOptionsCardBuilder {
19 mandate_options:
20 Option<Option<stripe_shared::SetupIntentPaymentMethodOptionsCardMandateOptions>>,
21 network: Option<Option<SetupIntentPaymentMethodOptionsCardNetwork>>,
22 request_three_d_secure: Option<Option<SetupIntentPaymentMethodOptionsCardRequestThreeDSecure>>,
23}
24
25#[allow(
26 unused_variables,
27 irrefutable_let_patterns,
28 clippy::let_unit_value,
29 clippy::match_single_binding,
30 clippy::single_match
31)]
32const _: () = {
33 use miniserde::de::{Map, Visitor};
34 use miniserde::json::Value;
35 use miniserde::{Deserialize, Result, make_place};
36 use stripe_types::miniserde_helpers::FromValueOpt;
37 use stripe_types::{MapBuilder, ObjectDeser};
38
39 make_place!(Place);
40
41 impl Deserialize for SetupIntentPaymentMethodOptionsCard {
42 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
43 Place::new(out)
44 }
45 }
46
47 struct Builder<'a> {
48 out: &'a mut Option<SetupIntentPaymentMethodOptionsCard>,
49 builder: SetupIntentPaymentMethodOptionsCardBuilder,
50 }
51
52 impl Visitor for Place<SetupIntentPaymentMethodOptionsCard> {
53 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
54 Ok(Box::new(Builder {
55 out: &mut self.out,
56 builder: SetupIntentPaymentMethodOptionsCardBuilder::deser_default(),
57 }))
58 }
59 }
60
61 impl MapBuilder for SetupIntentPaymentMethodOptionsCardBuilder {
62 type Out = SetupIntentPaymentMethodOptionsCard;
63 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
64 Ok(match k {
65 "mandate_options" => Deserialize::begin(&mut self.mandate_options),
66 "network" => Deserialize::begin(&mut self.network),
67 "request_three_d_secure" => Deserialize::begin(&mut self.request_three_d_secure),
68 _ => <dyn Visitor>::ignore(),
69 })
70 }
71
72 fn deser_default() -> Self {
73 Self {
74 mandate_options: Deserialize::default(),
75 network: Deserialize::default(),
76 request_three_d_secure: Deserialize::default(),
77 }
78 }
79
80 fn take_out(&mut self) -> Option<Self::Out> {
81 let (Some(mandate_options), Some(network), Some(request_three_d_secure)) =
82 (self.mandate_options.take(), self.network, self.request_three_d_secure)
83 else {
84 return None;
85 };
86 Some(Self::Out { mandate_options, network, request_three_d_secure })
87 }
88 }
89
90 impl Map for Builder<'_> {
91 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
92 self.builder.key(k)
93 }
94
95 fn finish(&mut self) -> Result<()> {
96 *self.out = self.builder.take_out();
97 Ok(())
98 }
99 }
100
101 impl ObjectDeser for SetupIntentPaymentMethodOptionsCard {
102 type Builder = SetupIntentPaymentMethodOptionsCardBuilder;
103 }
104
105 impl FromValueOpt for SetupIntentPaymentMethodOptionsCard {
106 fn from_value(v: Value) -> Option<Self> {
107 let Value::Object(obj) = v else {
108 return None;
109 };
110 let mut b = SetupIntentPaymentMethodOptionsCardBuilder::deser_default();
111 for (k, v) in obj {
112 match k.as_str() {
113 "mandate_options" => b.mandate_options = FromValueOpt::from_value(v),
114 "network" => b.network = FromValueOpt::from_value(v),
115 "request_three_d_secure" => {
116 b.request_three_d_secure = FromValueOpt::from_value(v)
117 }
118 _ => {}
119 }
120 }
121 b.take_out()
122 }
123 }
124};
125#[derive(Copy, Clone, Eq, PartialEq)]
129pub enum SetupIntentPaymentMethodOptionsCardNetwork {
130 Amex,
131 CartesBancaires,
132 Diners,
133 Discover,
134 EftposAu,
135 Girocard,
136 Interac,
137 Jcb,
138 Link,
139 Mastercard,
140 Unionpay,
141 Unknown,
142 Visa,
143}
144impl SetupIntentPaymentMethodOptionsCardNetwork {
145 pub fn as_str(self) -> &'static str {
146 use SetupIntentPaymentMethodOptionsCardNetwork::*;
147 match self {
148 Amex => "amex",
149 CartesBancaires => "cartes_bancaires",
150 Diners => "diners",
151 Discover => "discover",
152 EftposAu => "eftpos_au",
153 Girocard => "girocard",
154 Interac => "interac",
155 Jcb => "jcb",
156 Link => "link",
157 Mastercard => "mastercard",
158 Unionpay => "unionpay",
159 Unknown => "unknown",
160 Visa => "visa",
161 }
162 }
163}
164
165impl std::str::FromStr for SetupIntentPaymentMethodOptionsCardNetwork {
166 type Err = stripe_types::StripeParseError;
167 fn from_str(s: &str) -> Result<Self, Self::Err> {
168 use SetupIntentPaymentMethodOptionsCardNetwork::*;
169 match s {
170 "amex" => Ok(Amex),
171 "cartes_bancaires" => Ok(CartesBancaires),
172 "diners" => Ok(Diners),
173 "discover" => Ok(Discover),
174 "eftpos_au" => Ok(EftposAu),
175 "girocard" => Ok(Girocard),
176 "interac" => Ok(Interac),
177 "jcb" => Ok(Jcb),
178 "link" => Ok(Link),
179 "mastercard" => Ok(Mastercard),
180 "unionpay" => Ok(Unionpay),
181 "unknown" => Ok(Unknown),
182 "visa" => Ok(Visa),
183 _ => Err(stripe_types::StripeParseError),
184 }
185 }
186}
187impl std::fmt::Display for SetupIntentPaymentMethodOptionsCardNetwork {
188 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
189 f.write_str(self.as_str())
190 }
191}
192
193impl std::fmt::Debug for SetupIntentPaymentMethodOptionsCardNetwork {
194 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
195 f.write_str(self.as_str())
196 }
197}
198#[cfg(feature = "serialize")]
199impl serde::Serialize for SetupIntentPaymentMethodOptionsCardNetwork {
200 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
201 where
202 S: serde::Serializer,
203 {
204 serializer.serialize_str(self.as_str())
205 }
206}
207impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsCardNetwork {
208 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
209 crate::Place::new(out)
210 }
211}
212
213impl miniserde::de::Visitor for crate::Place<SetupIntentPaymentMethodOptionsCardNetwork> {
214 fn string(&mut self, s: &str) -> miniserde::Result<()> {
215 use std::str::FromStr;
216 self.out = Some(
217 SetupIntentPaymentMethodOptionsCardNetwork::from_str(s)
218 .map_err(|_| miniserde::Error)?,
219 );
220 Ok(())
221 }
222}
223
224stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsCardNetwork);
225#[cfg(feature = "deserialize")]
226impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsCardNetwork {
227 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
228 use std::str::FromStr;
229 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
230 Self::from_str(&s).map_err(|_| {
231 serde::de::Error::custom("Unknown value for SetupIntentPaymentMethodOptionsCardNetwork")
232 })
233 }
234}
235#[derive(Copy, Clone, Eq, PartialEq)]
240pub enum SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
241 Any,
242 Automatic,
243 Challenge,
244}
245impl SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
246 pub fn as_str(self) -> &'static str {
247 use SetupIntentPaymentMethodOptionsCardRequestThreeDSecure::*;
248 match self {
249 Any => "any",
250 Automatic => "automatic",
251 Challenge => "challenge",
252 }
253 }
254}
255
256impl std::str::FromStr for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
257 type Err = stripe_types::StripeParseError;
258 fn from_str(s: &str) -> Result<Self, Self::Err> {
259 use SetupIntentPaymentMethodOptionsCardRequestThreeDSecure::*;
260 match s {
261 "any" => Ok(Any),
262 "automatic" => Ok(Automatic),
263 "challenge" => Ok(Challenge),
264 _ => Err(stripe_types::StripeParseError),
265 }
266 }
267}
268impl std::fmt::Display for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
269 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
270 f.write_str(self.as_str())
271 }
272}
273
274impl std::fmt::Debug for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
275 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
276 f.write_str(self.as_str())
277 }
278}
279#[cfg(feature = "serialize")]
280impl serde::Serialize for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
281 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
282 where
283 S: serde::Serializer,
284 {
285 serializer.serialize_str(self.as_str())
286 }
287}
288impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
289 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
290 crate::Place::new(out)
291 }
292}
293
294impl miniserde::de::Visitor
295 for crate::Place<SetupIntentPaymentMethodOptionsCardRequestThreeDSecure>
296{
297 fn string(&mut self, s: &str) -> miniserde::Result<()> {
298 use std::str::FromStr;
299 self.out = Some(
300 SetupIntentPaymentMethodOptionsCardRequestThreeDSecure::from_str(s)
301 .map_err(|_| miniserde::Error)?,
302 );
303 Ok(())
304 }
305}
306
307stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsCardRequestThreeDSecure);
308#[cfg(feature = "deserialize")]
309impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
310 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
311 use std::str::FromStr;
312 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
313 Self::from_str(&s).map_err(|_| {
314 serde::de::Error::custom(
315 "Unknown value for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure",
316 )
317 })
318 }
319}