stripe_shared/
payment_method_options_cashapp.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 PaymentMethodOptionsCashapp {
6 pub capture_method: Option<PaymentMethodOptionsCashappCaptureMethod>,
8 pub setup_future_usage: Option<PaymentMethodOptionsCashappSetupFutureUsage>,
17}
18#[cfg(feature = "redact-generated-debug")]
19impl std::fmt::Debug for PaymentMethodOptionsCashapp {
20 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
21 f.debug_struct("PaymentMethodOptionsCashapp").finish_non_exhaustive()
22 }
23}
24#[doc(hidden)]
25pub struct PaymentMethodOptionsCashappBuilder {
26 capture_method: Option<Option<PaymentMethodOptionsCashappCaptureMethod>>,
27 setup_future_usage: Option<Option<PaymentMethodOptionsCashappSetupFutureUsage>>,
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 PaymentMethodOptionsCashapp {
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<PaymentMethodOptionsCashapp>,
54 builder: PaymentMethodOptionsCashappBuilder,
55 }
56
57 impl Visitor for Place<PaymentMethodOptionsCashapp> {
58 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
59 Ok(Box::new(Builder {
60 out: &mut self.out,
61 builder: PaymentMethodOptionsCashappBuilder::deser_default(),
62 }))
63 }
64 }
65
66 impl MapBuilder for PaymentMethodOptionsCashappBuilder {
67 type Out = PaymentMethodOptionsCashapp;
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 "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
72 _ => <dyn Visitor>::ignore(),
73 })
74 }
75
76 fn deser_default() -> Self {
77 Self { capture_method: Some(None), setup_future_usage: Some(None) }
78 }
79
80 fn take_out(&mut self) -> Option<Self::Out> {
81 let (Some(capture_method), Some(setup_future_usage)) =
82 (self.capture_method.take(), self.setup_future_usage.take())
83 else {
84 return None;
85 };
86 Some(Self::Out { capture_method, setup_future_usage })
87 }
88 }
89
90 impl Map for Builder<'_> {
91 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
92 self.builder.key(k)
93 }
94
95 fn finish(&mut self) -> Result<()> {
96 *self.out = self.builder.take_out();
97 Ok(())
98 }
99 }
100
101 impl ObjectDeser for PaymentMethodOptionsCashapp {
102 type Builder = PaymentMethodOptionsCashappBuilder;
103 }
104
105 impl FromValueOpt for PaymentMethodOptionsCashapp {
106 fn from_value(v: Value) -> Option<Self> {
107 let Value::Object(obj) = v else {
108 return None;
109 };
110 let mut b = PaymentMethodOptionsCashappBuilder::deser_default();
111 for (k, v) in obj {
112 match k.as_str() {
113 "capture_method" => b.capture_method = FromValueOpt::from_value(v),
114 "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
115 _ => {}
116 }
117 }
118 b.take_out()
119 }
120 }
121};
122#[derive(Clone, Eq, PartialEq)]
124#[non_exhaustive]
125pub enum PaymentMethodOptionsCashappCaptureMethod {
126 Manual,
127 Unknown(String),
129}
130impl PaymentMethodOptionsCashappCaptureMethod {
131 pub fn as_str(&self) -> &str {
132 use PaymentMethodOptionsCashappCaptureMethod::*;
133 match self {
134 Manual => "manual",
135 Unknown(v) => v,
136 }
137 }
138}
139
140impl std::str::FromStr for PaymentMethodOptionsCashappCaptureMethod {
141 type Err = std::convert::Infallible;
142 fn from_str(s: &str) -> Result<Self, Self::Err> {
143 use PaymentMethodOptionsCashappCaptureMethod::*;
144 match s {
145 "manual" => Ok(Manual),
146 v => {
147 tracing::warn!(
148 "Unknown value '{}' for enum '{}'",
149 v,
150 "PaymentMethodOptionsCashappCaptureMethod"
151 );
152 Ok(Unknown(v.to_owned()))
153 }
154 }
155 }
156}
157impl std::fmt::Display for PaymentMethodOptionsCashappCaptureMethod {
158 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
159 f.write_str(self.as_str())
160 }
161}
162
163#[cfg(not(feature = "redact-generated-debug"))]
164impl std::fmt::Debug for PaymentMethodOptionsCashappCaptureMethod {
165 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
166 f.write_str(self.as_str())
167 }
168}
169#[cfg(feature = "redact-generated-debug")]
170impl std::fmt::Debug for PaymentMethodOptionsCashappCaptureMethod {
171 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
172 f.debug_struct(stringify!(PaymentMethodOptionsCashappCaptureMethod)).finish_non_exhaustive()
173 }
174}
175#[cfg(feature = "serialize")]
176impl serde::Serialize for PaymentMethodOptionsCashappCaptureMethod {
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 PaymentMethodOptionsCashappCaptureMethod {
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<PaymentMethodOptionsCashappCaptureMethod> {
191 fn string(&mut self, s: &str) -> miniserde::Result<()> {
192 use std::str::FromStr;
193 self.out = Some(PaymentMethodOptionsCashappCaptureMethod::from_str(s).expect("infallible"));
194 Ok(())
195 }
196}
197
198stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCashappCaptureMethod);
199#[cfg(feature = "deserialize")]
200impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCashappCaptureMethod {
201 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
202 use std::str::FromStr;
203 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
204 Ok(Self::from_str(&s).expect("infallible"))
205 }
206}
207#[derive(Clone, Eq, PartialEq)]
216#[non_exhaustive]
217pub enum PaymentMethodOptionsCashappSetupFutureUsage {
218 None,
219 OffSession,
220 OnSession,
221 Unknown(String),
223}
224impl PaymentMethodOptionsCashappSetupFutureUsage {
225 pub fn as_str(&self) -> &str {
226 use PaymentMethodOptionsCashappSetupFutureUsage::*;
227 match self {
228 None => "none",
229 OffSession => "off_session",
230 OnSession => "on_session",
231 Unknown(v) => v,
232 }
233 }
234}
235
236impl std::str::FromStr for PaymentMethodOptionsCashappSetupFutureUsage {
237 type Err = std::convert::Infallible;
238 fn from_str(s: &str) -> Result<Self, Self::Err> {
239 use PaymentMethodOptionsCashappSetupFutureUsage::*;
240 match s {
241 "none" => Ok(None),
242 "off_session" => Ok(OffSession),
243 "on_session" => Ok(OnSession),
244 v => {
245 tracing::warn!(
246 "Unknown value '{}' for enum '{}'",
247 v,
248 "PaymentMethodOptionsCashappSetupFutureUsage"
249 );
250 Ok(Unknown(v.to_owned()))
251 }
252 }
253 }
254}
255impl std::fmt::Display for PaymentMethodOptionsCashappSetupFutureUsage {
256 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
257 f.write_str(self.as_str())
258 }
259}
260
261#[cfg(not(feature = "redact-generated-debug"))]
262impl std::fmt::Debug for PaymentMethodOptionsCashappSetupFutureUsage {
263 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
264 f.write_str(self.as_str())
265 }
266}
267#[cfg(feature = "redact-generated-debug")]
268impl std::fmt::Debug for PaymentMethodOptionsCashappSetupFutureUsage {
269 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
270 f.debug_struct(stringify!(PaymentMethodOptionsCashappSetupFutureUsage))
271 .finish_non_exhaustive()
272 }
273}
274#[cfg(feature = "serialize")]
275impl serde::Serialize for PaymentMethodOptionsCashappSetupFutureUsage {
276 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
277 where
278 S: serde::Serializer,
279 {
280 serializer.serialize_str(self.as_str())
281 }
282}
283impl miniserde::Deserialize for PaymentMethodOptionsCashappSetupFutureUsage {
284 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
285 crate::Place::new(out)
286 }
287}
288
289impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsCashappSetupFutureUsage> {
290 fn string(&mut self, s: &str) -> miniserde::Result<()> {
291 use std::str::FromStr;
292 self.out =
293 Some(PaymentMethodOptionsCashappSetupFutureUsage::from_str(s).expect("infallible"));
294 Ok(())
295 }
296}
297
298stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCashappSetupFutureUsage);
299#[cfg(feature = "deserialize")]
300impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCashappSetupFutureUsage {
301 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
302 use std::str::FromStr;
303 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
304 Ok(Self::from_str(&s).expect("infallible"))
305 }
306}