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