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