1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentMethodOptionsPaypal {
5 pub capture_method: Option<PaymentMethodOptionsPaypalCaptureMethod>,
7 pub preferred_locale: Option<String>,
9 pub reference: Option<String>,
12 pub setup_future_usage: Option<PaymentMethodOptionsPaypalSetupFutureUsage>,
21}
22#[doc(hidden)]
23pub struct PaymentMethodOptionsPaypalBuilder {
24 capture_method: Option<Option<PaymentMethodOptionsPaypalCaptureMethod>>,
25 preferred_locale: Option<Option<String>>,
26 reference: Option<Option<String>>,
27 setup_future_usage: Option<Option<PaymentMethodOptionsPaypalSetupFutureUsage>>,
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 PaymentMethodOptionsPaypal {
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<PaymentMethodOptionsPaypal>,
54 builder: PaymentMethodOptionsPaypalBuilder,
55 }
56
57 impl Visitor for Place<PaymentMethodOptionsPaypal> {
58 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
59 Ok(Box::new(Builder {
60 out: &mut self.out,
61 builder: PaymentMethodOptionsPaypalBuilder::deser_default(),
62 }))
63 }
64 }
65
66 impl MapBuilder for PaymentMethodOptionsPaypalBuilder {
67 type Out = PaymentMethodOptionsPaypal;
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 PaymentMethodOptionsPaypal {
119 type Builder = PaymentMethodOptionsPaypalBuilder;
120 }
121
122 impl FromValueOpt for PaymentMethodOptionsPaypal {
123 fn from_value(v: Value) -> Option<Self> {
124 let Value::Object(obj) = v else {
125 return None;
126 };
127 let mut b = PaymentMethodOptionsPaypalBuilder::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 PaymentMethodOptionsPaypalCaptureMethod {
145 Manual,
146}
147impl PaymentMethodOptionsPaypalCaptureMethod {
148 pub fn as_str(self) -> &'static str {
149 use PaymentMethodOptionsPaypalCaptureMethod::*;
150 match self {
151 Manual => "manual",
152 }
153 }
154}
155
156impl std::str::FromStr for PaymentMethodOptionsPaypalCaptureMethod {
157 type Err = stripe_types::StripeParseError;
158 fn from_str(s: &str) -> Result<Self, Self::Err> {
159 use PaymentMethodOptionsPaypalCaptureMethod::*;
160 match s {
161 "manual" => Ok(Manual),
162 _ => Err(stripe_types::StripeParseError),
163 }
164 }
165}
166impl std::fmt::Display for PaymentMethodOptionsPaypalCaptureMethod {
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 PaymentMethodOptionsPaypalCaptureMethod {
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 PaymentMethodOptionsPaypalCaptureMethod {
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 PaymentMethodOptionsPaypalCaptureMethod {
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<PaymentMethodOptionsPaypalCaptureMethod> {
193 fn string(&mut self, s: &str) -> miniserde::Result<()> {
194 use std::str::FromStr;
195 self.out = Some(
196 PaymentMethodOptionsPaypalCaptureMethod::from_str(s).map_err(|_| miniserde::Error)?,
197 );
198 Ok(())
199 }
200}
201
202stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsPaypalCaptureMethod);
203#[cfg(feature = "deserialize")]
204impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsPaypalCaptureMethod {
205 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
206 use std::str::FromStr;
207 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
208 Self::from_str(&s).map_err(|_| {
209 serde::de::Error::custom("Unknown value for PaymentMethodOptionsPaypalCaptureMethod")
210 })
211 }
212}
213#[derive(Copy, Clone, Eq, PartialEq)]
222pub enum PaymentMethodOptionsPaypalSetupFutureUsage {
223 None,
224 OffSession,
225}
226impl PaymentMethodOptionsPaypalSetupFutureUsage {
227 pub fn as_str(self) -> &'static str {
228 use PaymentMethodOptionsPaypalSetupFutureUsage::*;
229 match self {
230 None => "none",
231 OffSession => "off_session",
232 }
233 }
234}
235
236impl std::str::FromStr for PaymentMethodOptionsPaypalSetupFutureUsage {
237 type Err = stripe_types::StripeParseError;
238 fn from_str(s: &str) -> Result<Self, Self::Err> {
239 use PaymentMethodOptionsPaypalSetupFutureUsage::*;
240 match s {
241 "none" => Ok(None),
242 "off_session" => Ok(OffSession),
243 _ => Err(stripe_types::StripeParseError),
244 }
245 }
246}
247impl std::fmt::Display for PaymentMethodOptionsPaypalSetupFutureUsage {
248 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
249 f.write_str(self.as_str())
250 }
251}
252
253impl std::fmt::Debug for PaymentMethodOptionsPaypalSetupFutureUsage {
254 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
255 f.write_str(self.as_str())
256 }
257}
258#[cfg(feature = "serialize")]
259impl serde::Serialize for PaymentMethodOptionsPaypalSetupFutureUsage {
260 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
261 where
262 S: serde::Serializer,
263 {
264 serializer.serialize_str(self.as_str())
265 }
266}
267impl miniserde::Deserialize for PaymentMethodOptionsPaypalSetupFutureUsage {
268 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
269 crate::Place::new(out)
270 }
271}
272
273impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsPaypalSetupFutureUsage> {
274 fn string(&mut self, s: &str) -> miniserde::Result<()> {
275 use std::str::FromStr;
276 self.out = Some(
277 PaymentMethodOptionsPaypalSetupFutureUsage::from_str(s)
278 .map_err(|_| miniserde::Error)?,
279 );
280 Ok(())
281 }
282}
283
284stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsPaypalSetupFutureUsage);
285#[cfg(feature = "deserialize")]
286impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsPaypalSetupFutureUsage {
287 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
288 use std::str::FromStr;
289 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
290 Self::from_str(&s).map_err(|_| {
291 serde::de::Error::custom("Unknown value for PaymentMethodOptionsPaypalSetupFutureUsage")
292 })
293 }
294}