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