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