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