1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentMethodOptionsSofort {
5 pub preferred_language: Option<PaymentMethodOptionsSofortPreferredLanguage>,
7 pub setup_future_usage: Option<PaymentMethodOptionsSofortSetupFutureUsage>,
16}
17#[doc(hidden)]
18pub struct PaymentMethodOptionsSofortBuilder {
19 preferred_language: Option<Option<PaymentMethodOptionsSofortPreferredLanguage>>,
20 setup_future_usage: Option<Option<PaymentMethodOptionsSofortSetupFutureUsage>>,
21}
22
23#[allow(
24 unused_variables,
25 irrefutable_let_patterns,
26 clippy::let_unit_value,
27 clippy::match_single_binding,
28 clippy::single_match
29)]
30const _: () = {
31 use miniserde::de::{Map, Visitor};
32 use miniserde::json::Value;
33 use miniserde::{Deserialize, Result, make_place};
34 use stripe_types::miniserde_helpers::FromValueOpt;
35 use stripe_types::{MapBuilder, ObjectDeser};
36
37 make_place!(Place);
38
39 impl Deserialize for PaymentMethodOptionsSofort {
40 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
41 Place::new(out)
42 }
43 }
44
45 struct Builder<'a> {
46 out: &'a mut Option<PaymentMethodOptionsSofort>,
47 builder: PaymentMethodOptionsSofortBuilder,
48 }
49
50 impl Visitor for Place<PaymentMethodOptionsSofort> {
51 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
52 Ok(Box::new(Builder {
53 out: &mut self.out,
54 builder: PaymentMethodOptionsSofortBuilder::deser_default(),
55 }))
56 }
57 }
58
59 impl MapBuilder for PaymentMethodOptionsSofortBuilder {
60 type Out = PaymentMethodOptionsSofort;
61 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
62 Ok(match k {
63 "preferred_language" => Deserialize::begin(&mut self.preferred_language),
64 "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
65 _ => <dyn Visitor>::ignore(),
66 })
67 }
68
69 fn deser_default() -> Self {
70 Self {
71 preferred_language: Deserialize::default(),
72 setup_future_usage: Deserialize::default(),
73 }
74 }
75
76 fn take_out(&mut self) -> Option<Self::Out> {
77 let (Some(preferred_language), Some(setup_future_usage)) =
78 (self.preferred_language.take(), self.setup_future_usage.take())
79 else {
80 return None;
81 };
82 Some(Self::Out { preferred_language, setup_future_usage })
83 }
84 }
85
86 impl Map for Builder<'_> {
87 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
88 self.builder.key(k)
89 }
90
91 fn finish(&mut self) -> Result<()> {
92 *self.out = self.builder.take_out();
93 Ok(())
94 }
95 }
96
97 impl ObjectDeser for PaymentMethodOptionsSofort {
98 type Builder = PaymentMethodOptionsSofortBuilder;
99 }
100
101 impl FromValueOpt for PaymentMethodOptionsSofort {
102 fn from_value(v: Value) -> Option<Self> {
103 let Value::Object(obj) = v else {
104 return None;
105 };
106 let mut b = PaymentMethodOptionsSofortBuilder::deser_default();
107 for (k, v) in obj {
108 match k.as_str() {
109 "preferred_language" => b.preferred_language = FromValueOpt::from_value(v),
110 "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
111 _ => {}
112 }
113 }
114 b.take_out()
115 }
116 }
117};
118#[derive(Clone, Eq, PartialEq)]
120#[non_exhaustive]
121pub enum PaymentMethodOptionsSofortPreferredLanguage {
122 De,
123 En,
124 Es,
125 Fr,
126 It,
127 Nl,
128 Pl,
129 Unknown(String),
131}
132impl PaymentMethodOptionsSofortPreferredLanguage {
133 pub fn as_str(&self) -> &str {
134 use PaymentMethodOptionsSofortPreferredLanguage::*;
135 match self {
136 De => "de",
137 En => "en",
138 Es => "es",
139 Fr => "fr",
140 It => "it",
141 Nl => "nl",
142 Pl => "pl",
143 Unknown(v) => v,
144 }
145 }
146}
147
148impl std::str::FromStr for PaymentMethodOptionsSofortPreferredLanguage {
149 type Err = std::convert::Infallible;
150 fn from_str(s: &str) -> Result<Self, Self::Err> {
151 use PaymentMethodOptionsSofortPreferredLanguage::*;
152 match s {
153 "de" => Ok(De),
154 "en" => Ok(En),
155 "es" => Ok(Es),
156 "fr" => Ok(Fr),
157 "it" => Ok(It),
158 "nl" => Ok(Nl),
159 "pl" => Ok(Pl),
160 v => {
161 tracing::warn!(
162 "Unknown value '{}' for enum '{}'",
163 v,
164 "PaymentMethodOptionsSofortPreferredLanguage"
165 );
166 Ok(Unknown(v.to_owned()))
167 }
168 }
169 }
170}
171impl std::fmt::Display for PaymentMethodOptionsSofortPreferredLanguage {
172 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
173 f.write_str(self.as_str())
174 }
175}
176
177impl std::fmt::Debug for PaymentMethodOptionsSofortPreferredLanguage {
178 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
179 f.write_str(self.as_str())
180 }
181}
182#[cfg(feature = "serialize")]
183impl serde::Serialize for PaymentMethodOptionsSofortPreferredLanguage {
184 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
185 where
186 S: serde::Serializer,
187 {
188 serializer.serialize_str(self.as_str())
189 }
190}
191impl miniserde::Deserialize for PaymentMethodOptionsSofortPreferredLanguage {
192 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
193 crate::Place::new(out)
194 }
195}
196
197impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsSofortPreferredLanguage> {
198 fn string(&mut self, s: &str) -> miniserde::Result<()> {
199 use std::str::FromStr;
200 self.out =
201 Some(PaymentMethodOptionsSofortPreferredLanguage::from_str(s).expect("infallible"));
202 Ok(())
203 }
204}
205
206stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsSofortPreferredLanguage);
207#[cfg(feature = "deserialize")]
208impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsSofortPreferredLanguage {
209 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
210 use std::str::FromStr;
211 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
212 Ok(Self::from_str(&s).expect("infallible"))
213 }
214}
215#[derive(Clone, Eq, PartialEq)]
224#[non_exhaustive]
225pub enum PaymentMethodOptionsSofortSetupFutureUsage {
226 None,
227 OffSession,
228 Unknown(String),
230}
231impl PaymentMethodOptionsSofortSetupFutureUsage {
232 pub fn as_str(&self) -> &str {
233 use PaymentMethodOptionsSofortSetupFutureUsage::*;
234 match self {
235 None => "none",
236 OffSession => "off_session",
237 Unknown(v) => v,
238 }
239 }
240}
241
242impl std::str::FromStr for PaymentMethodOptionsSofortSetupFutureUsage {
243 type Err = std::convert::Infallible;
244 fn from_str(s: &str) -> Result<Self, Self::Err> {
245 use PaymentMethodOptionsSofortSetupFutureUsage::*;
246 match s {
247 "none" => Ok(None),
248 "off_session" => Ok(OffSession),
249 v => {
250 tracing::warn!(
251 "Unknown value '{}' for enum '{}'",
252 v,
253 "PaymentMethodOptionsSofortSetupFutureUsage"
254 );
255 Ok(Unknown(v.to_owned()))
256 }
257 }
258 }
259}
260impl std::fmt::Display for PaymentMethodOptionsSofortSetupFutureUsage {
261 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
262 f.write_str(self.as_str())
263 }
264}
265
266impl std::fmt::Debug for PaymentMethodOptionsSofortSetupFutureUsage {
267 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
268 f.write_str(self.as_str())
269 }
270}
271#[cfg(feature = "serialize")]
272impl serde::Serialize for PaymentMethodOptionsSofortSetupFutureUsage {
273 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
274 where
275 S: serde::Serializer,
276 {
277 serializer.serialize_str(self.as_str())
278 }
279}
280impl miniserde::Deserialize for PaymentMethodOptionsSofortSetupFutureUsage {
281 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
282 crate::Place::new(out)
283 }
284}
285
286impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsSofortSetupFutureUsage> {
287 fn string(&mut self, s: &str) -> miniserde::Result<()> {
288 use std::str::FromStr;
289 self.out =
290 Some(PaymentMethodOptionsSofortSetupFutureUsage::from_str(s).expect("infallible"));
291 Ok(())
292 }
293}
294
295stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsSofortSetupFutureUsage);
296#[cfg(feature = "deserialize")]
297impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsSofortSetupFutureUsage {
298 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
299 use std::str::FromStr;
300 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
301 Ok(Self::from_str(&s).expect("infallible"))
302 }
303}