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