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::{make_place, Deserialize, Result};
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
69 _ => <dyn Visitor>::ignore(),
70 })
71 }
72
73 fn deser_default() -> Self {
74 Self {
75 mandate_options: Deserialize::default(),
76 network: Deserialize::default(),
77 request_three_d_secure: Deserialize::default(),
78 }
79 }
80
81 fn take_out(&mut self) -> Option<Self::Out> {
82 let (Some(mandate_options), Some(network), Some(request_three_d_secure)) =
83 (self.mandate_options.take(), self.network, self.request_three_d_secure)
84 else {
85 return None;
86 };
87 Some(Self::Out { mandate_options, network, request_three_d_secure })
88 }
89 }
90
91 impl Map for Builder<'_> {
92 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
93 self.builder.key(k)
94 }
95
96 fn finish(&mut self) -> Result<()> {
97 *self.out = self.builder.take_out();
98 Ok(())
99 }
100 }
101
102 impl ObjectDeser for SetupIntentPaymentMethodOptionsCard {
103 type Builder = SetupIntentPaymentMethodOptionsCardBuilder;
104 }
105
106 impl FromValueOpt for SetupIntentPaymentMethodOptionsCard {
107 fn from_value(v: Value) -> Option<Self> {
108 let Value::Object(obj) = v else {
109 return None;
110 };
111 let mut b = SetupIntentPaymentMethodOptionsCardBuilder::deser_default();
112 for (k, v) in obj {
113 match k.as_str() {
114 "mandate_options" => b.mandate_options = FromValueOpt::from_value(v),
115 "network" => b.network = FromValueOpt::from_value(v),
116 "request_three_d_secure" => {
117 b.request_three_d_secure = FromValueOpt::from_value(v)
118 }
119
120 _ => {}
121 }
122 }
123 b.take_out()
124 }
125 }
126};
127#[derive(Copy, Clone, Eq, PartialEq)]
131pub enum SetupIntentPaymentMethodOptionsCardNetwork {
132 Amex,
133 CartesBancaires,
134 Diners,
135 Discover,
136 EftposAu,
137 Girocard,
138 Interac,
139 Jcb,
140 Link,
141 Mastercard,
142 Unionpay,
143 Unknown,
144 Visa,
145}
146impl SetupIntentPaymentMethodOptionsCardNetwork {
147 pub fn as_str(self) -> &'static str {
148 use SetupIntentPaymentMethodOptionsCardNetwork::*;
149 match self {
150 Amex => "amex",
151 CartesBancaires => "cartes_bancaires",
152 Diners => "diners",
153 Discover => "discover",
154 EftposAu => "eftpos_au",
155 Girocard => "girocard",
156 Interac => "interac",
157 Jcb => "jcb",
158 Link => "link",
159 Mastercard => "mastercard",
160 Unionpay => "unionpay",
161 Unknown => "unknown",
162 Visa => "visa",
163 }
164 }
165}
166
167impl std::str::FromStr for SetupIntentPaymentMethodOptionsCardNetwork {
168 type Err = stripe_types::StripeParseError;
169 fn from_str(s: &str) -> Result<Self, Self::Err> {
170 use SetupIntentPaymentMethodOptionsCardNetwork::*;
171 match s {
172 "amex" => Ok(Amex),
173 "cartes_bancaires" => Ok(CartesBancaires),
174 "diners" => Ok(Diners),
175 "discover" => Ok(Discover),
176 "eftpos_au" => Ok(EftposAu),
177 "girocard" => Ok(Girocard),
178 "interac" => Ok(Interac),
179 "jcb" => Ok(Jcb),
180 "link" => Ok(Link),
181 "mastercard" => Ok(Mastercard),
182 "unionpay" => Ok(Unionpay),
183 "unknown" => Ok(Unknown),
184 "visa" => Ok(Visa),
185 _ => Err(stripe_types::StripeParseError),
186 }
187 }
188}
189impl std::fmt::Display for SetupIntentPaymentMethodOptionsCardNetwork {
190 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
191 f.write_str(self.as_str())
192 }
193}
194
195impl std::fmt::Debug for SetupIntentPaymentMethodOptionsCardNetwork {
196 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
197 f.write_str(self.as_str())
198 }
199}
200#[cfg(feature = "serialize")]
201impl serde::Serialize for SetupIntentPaymentMethodOptionsCardNetwork {
202 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
203 where
204 S: serde::Serializer,
205 {
206 serializer.serialize_str(self.as_str())
207 }
208}
209impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsCardNetwork {
210 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
211 crate::Place::new(out)
212 }
213}
214
215impl miniserde::de::Visitor for crate::Place<SetupIntentPaymentMethodOptionsCardNetwork> {
216 fn string(&mut self, s: &str) -> miniserde::Result<()> {
217 use std::str::FromStr;
218 self.out = Some(
219 SetupIntentPaymentMethodOptionsCardNetwork::from_str(s)
220 .map_err(|_| miniserde::Error)?,
221 );
222 Ok(())
223 }
224}
225
226stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsCardNetwork);
227#[cfg(feature = "deserialize")]
228impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsCardNetwork {
229 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
230 use std::str::FromStr;
231 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
232 Self::from_str(&s).map_err(|_| {
233 serde::de::Error::custom("Unknown value for SetupIntentPaymentMethodOptionsCardNetwork")
234 })
235 }
236}
237#[derive(Copy, Clone, Eq, PartialEq)]
242pub enum SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
243 Any,
244 Automatic,
245 Challenge,
246}
247impl SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
248 pub fn as_str(self) -> &'static str {
249 use SetupIntentPaymentMethodOptionsCardRequestThreeDSecure::*;
250 match self {
251 Any => "any",
252 Automatic => "automatic",
253 Challenge => "challenge",
254 }
255 }
256}
257
258impl std::str::FromStr for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
259 type Err = stripe_types::StripeParseError;
260 fn from_str(s: &str) -> Result<Self, Self::Err> {
261 use SetupIntentPaymentMethodOptionsCardRequestThreeDSecure::*;
262 match s {
263 "any" => Ok(Any),
264 "automatic" => Ok(Automatic),
265 "challenge" => Ok(Challenge),
266 _ => Err(stripe_types::StripeParseError),
267 }
268 }
269}
270impl std::fmt::Display for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
271 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
272 f.write_str(self.as_str())
273 }
274}
275
276impl std::fmt::Debug for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
277 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
278 f.write_str(self.as_str())
279 }
280}
281#[cfg(feature = "serialize")]
282impl serde::Serialize for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
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 SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
291 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
292 crate::Place::new(out)
293 }
294}
295
296impl miniserde::de::Visitor
297 for crate::Place<SetupIntentPaymentMethodOptionsCardRequestThreeDSecure>
298{
299 fn string(&mut self, s: &str) -> miniserde::Result<()> {
300 use std::str::FromStr;
301 self.out = Some(
302 SetupIntentPaymentMethodOptionsCardRequestThreeDSecure::from_str(s)
303 .map_err(|_| miniserde::Error)?,
304 );
305 Ok(())
306 }
307}
308
309stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsCardRequestThreeDSecure);
310#[cfg(feature = "deserialize")]
311impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
312 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
313 use std::str::FromStr;
314 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
315 Self::from_str(&s).map_err(|_| {
316 serde::de::Error::custom(
317 "Unknown value for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure",
318 )
319 })
320 }
321}