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