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::{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 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 _ => <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 PaymentMethodOptionsPaypal {
118 type Builder = PaymentMethodOptionsPaypalBuilder;
119 }
120
121 impl FromValueOpt for PaymentMethodOptionsPaypal {
122 fn from_value(v: Value) -> Option<Self> {
123 let Value::Object(obj) = v else {
124 return None;
125 };
126 let mut b = PaymentMethodOptionsPaypalBuilder::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 PaymentMethodOptionsPaypalCaptureMethod {
143 Manual,
144}
145impl PaymentMethodOptionsPaypalCaptureMethod {
146 pub fn as_str(self) -> &'static str {
147 use PaymentMethodOptionsPaypalCaptureMethod::*;
148 match self {
149 Manual => "manual",
150 }
151 }
152}
153
154impl std::str::FromStr for PaymentMethodOptionsPaypalCaptureMethod {
155 type Err = stripe_types::StripeParseError;
156 fn from_str(s: &str) -> Result<Self, Self::Err> {
157 use PaymentMethodOptionsPaypalCaptureMethod::*;
158 match s {
159 "manual" => Ok(Manual),
160 _ => Err(stripe_types::StripeParseError),
161 }
162 }
163}
164impl std::fmt::Display for PaymentMethodOptionsPaypalCaptureMethod {
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 PaymentMethodOptionsPaypalCaptureMethod {
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 PaymentMethodOptionsPaypalCaptureMethod {
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 PaymentMethodOptionsPaypalCaptureMethod {
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<PaymentMethodOptionsPaypalCaptureMethod> {
191 fn string(&mut self, s: &str) -> miniserde::Result<()> {
192 use std::str::FromStr;
193 self.out = Some(
194 PaymentMethodOptionsPaypalCaptureMethod::from_str(s).map_err(|_| miniserde::Error)?,
195 );
196 Ok(())
197 }
198}
199
200stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsPaypalCaptureMethod);
201#[cfg(feature = "deserialize")]
202impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsPaypalCaptureMethod {
203 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
204 use std::str::FromStr;
205 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
206 Self::from_str(&s).map_err(|_| {
207 serde::de::Error::custom("Unknown value for PaymentMethodOptionsPaypalCaptureMethod")
208 })
209 }
210}
211#[derive(Copy, Clone, Eq, PartialEq)]
220pub enum PaymentMethodOptionsPaypalSetupFutureUsage {
221 None,
222 OffSession,
223}
224impl PaymentMethodOptionsPaypalSetupFutureUsage {
225 pub fn as_str(self) -> &'static str {
226 use PaymentMethodOptionsPaypalSetupFutureUsage::*;
227 match self {
228 None => "none",
229 OffSession => "off_session",
230 }
231 }
232}
233
234impl std::str::FromStr for PaymentMethodOptionsPaypalSetupFutureUsage {
235 type Err = stripe_types::StripeParseError;
236 fn from_str(s: &str) -> Result<Self, Self::Err> {
237 use PaymentMethodOptionsPaypalSetupFutureUsage::*;
238 match s {
239 "none" => Ok(None),
240 "off_session" => Ok(OffSession),
241 _ => Err(stripe_types::StripeParseError),
242 }
243 }
244}
245impl std::fmt::Display for PaymentMethodOptionsPaypalSetupFutureUsage {
246 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
247 f.write_str(self.as_str())
248 }
249}
250
251impl std::fmt::Debug for PaymentMethodOptionsPaypalSetupFutureUsage {
252 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
253 f.write_str(self.as_str())
254 }
255}
256#[cfg(feature = "serialize")]
257impl serde::Serialize for PaymentMethodOptionsPaypalSetupFutureUsage {
258 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
259 where
260 S: serde::Serializer,
261 {
262 serializer.serialize_str(self.as_str())
263 }
264}
265impl miniserde::Deserialize for PaymentMethodOptionsPaypalSetupFutureUsage {
266 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
267 crate::Place::new(out)
268 }
269}
270
271impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsPaypalSetupFutureUsage> {
272 fn string(&mut self, s: &str) -> miniserde::Result<()> {
273 use std::str::FromStr;
274 self.out = Some(
275 PaymentMethodOptionsPaypalSetupFutureUsage::from_str(s)
276 .map_err(|_| miniserde::Error)?,
277 );
278 Ok(())
279 }
280}
281
282stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsPaypalSetupFutureUsage);
283#[cfg(feature = "deserialize")]
284impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsPaypalSetupFutureUsage {
285 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
286 use std::str::FromStr;
287 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
288 Self::from_str(&s).map_err(|_| {
289 serde::de::Error::custom("Unknown value for PaymentMethodOptionsPaypalSetupFutureUsage")
290 })
291 }
292}