stripe_shared/
payment_flows_private_payment_methods_payco_payment_method_options.rs

1#[derive(Copy, Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptions {
5    /// Controls when the funds will be captured from the customer's account.
6    pub capture_method:
7        Option<PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod>,
8}
9#[doc(hidden)]
10pub struct PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsBuilder {
11    capture_method:
12        Option<Option<PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod>>,
13}
14
15#[allow(
16    unused_variables,
17    irrefutable_let_patterns,
18    clippy::let_unit_value,
19    clippy::match_single_binding,
20    clippy::single_match
21)]
22const _: () = {
23    use miniserde::de::{Map, Visitor};
24    use miniserde::json::Value;
25    use miniserde::{Deserialize, Result, make_place};
26    use stripe_types::miniserde_helpers::FromValueOpt;
27    use stripe_types::{MapBuilder, ObjectDeser};
28
29    make_place!(Place);
30
31    impl Deserialize for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptions {
32        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
33            Place::new(out)
34        }
35    }
36
37    struct Builder<'a> {
38        out: &'a mut Option<PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptions>,
39        builder: PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsBuilder,
40    }
41
42    impl Visitor for Place<PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptions> {
43        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
44            Ok(Box::new(Builder {
45                out: &mut self.out,
46                builder:
47                    PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsBuilder::deser_default(
48                    ),
49            }))
50        }
51    }
52
53    impl MapBuilder for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsBuilder {
54        type Out = PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptions;
55        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
56            Ok(match k {
57                "capture_method" => Deserialize::begin(&mut self.capture_method),
58                _ => <dyn Visitor>::ignore(),
59            })
60        }
61
62        fn deser_default() -> Self {
63            Self { capture_method: Deserialize::default() }
64        }
65
66        fn take_out(&mut self) -> Option<Self::Out> {
67            let (Some(capture_method),) = (self.capture_method,) else {
68                return None;
69            };
70            Some(Self::Out { capture_method })
71        }
72    }
73
74    impl Map for Builder<'_> {
75        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
76            self.builder.key(k)
77        }
78
79        fn finish(&mut self) -> Result<()> {
80            *self.out = self.builder.take_out();
81            Ok(())
82        }
83    }
84
85    impl ObjectDeser for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptions {
86        type Builder = PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsBuilder;
87    }
88
89    impl FromValueOpt for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptions {
90        fn from_value(v: Value) -> Option<Self> {
91            let Value::Object(obj) = v else {
92                return None;
93            };
94            let mut b =
95                PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsBuilder::deser_default();
96            for (k, v) in obj {
97                match k.as_str() {
98                    "capture_method" => b.capture_method = FromValueOpt::from_value(v),
99                    _ => {}
100                }
101            }
102            b.take_out()
103        }
104    }
105};
106/// Controls when the funds will be captured from the customer's account.
107#[derive(Copy, Clone, Eq, PartialEq)]
108pub enum PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod {
109    Manual,
110}
111impl PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod {
112    pub fn as_str(self) -> &'static str {
113        use PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod::*;
114        match self {
115            Manual => "manual",
116        }
117    }
118}
119
120impl std::str::FromStr for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod {
121    type Err = stripe_types::StripeParseError;
122    fn from_str(s: &str) -> Result<Self, Self::Err> {
123        use PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod::*;
124        match s {
125            "manual" => Ok(Manual),
126            _ => Err(stripe_types::StripeParseError),
127        }
128    }
129}
130impl std::fmt::Display for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod {
131    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
132        f.write_str(self.as_str())
133    }
134}
135
136impl std::fmt::Debug for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod {
137    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
138        f.write_str(self.as_str())
139    }
140}
141#[cfg(feature = "serialize")]
142impl serde::Serialize for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod {
143    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
144    where
145        S: serde::Serializer,
146    {
147        serializer.serialize_str(self.as_str())
148    }
149}
150impl miniserde::Deserialize
151    for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod
152{
153    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
154        crate::Place::new(out)
155    }
156}
157
158impl miniserde::de::Visitor
159    for crate::Place<PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod>
160{
161    fn string(&mut self, s: &str) -> miniserde::Result<()> {
162        use std::str::FromStr;
163        self.out = Some(
164            PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod::from_str(s)
165                .map_err(|_| miniserde::Error)?,
166        );
167        Ok(())
168    }
169}
170
171stripe_types::impl_from_val_with_from_str!(
172    PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod
173);
174#[cfg(feature = "deserialize")]
175impl<'de> serde::Deserialize<'de>
176    for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod
177{
178    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
179        use std::str::FromStr;
180        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
181        Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod"))
182    }
183}