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