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