Skip to main content

stripe_shared/
setup_intent_next_action_verify_with_microdeposits.rs

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 SetupIntentNextActionVerifyWithMicrodeposits {
6    /// The timestamp when the microdeposits are expected to land.
7    pub arrival_date: stripe_types::Timestamp,
8    /// The URL for the hosted verification page, which allows customers to verify their bank account.
9    pub hosted_verification_url: String,
10    /// The type of the microdeposit sent to the customer.
11    /// Used to distinguish between different verification methods.
12    pub microdeposit_type: Option<SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType>,
13}
14#[cfg(feature = "redact-generated-debug")]
15impl std::fmt::Debug for SetupIntentNextActionVerifyWithMicrodeposits {
16    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
17        f.debug_struct("SetupIntentNextActionVerifyWithMicrodeposits").finish_non_exhaustive()
18    }
19}
20#[doc(hidden)]
21pub struct SetupIntentNextActionVerifyWithMicrodepositsBuilder {
22    arrival_date: Option<stripe_types::Timestamp>,
23    hosted_verification_url: Option<String>,
24    microdeposit_type: Option<Option<SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType>>,
25}
26
27#[allow(
28    unused_variables,
29    irrefutable_let_patterns,
30    clippy::let_unit_value,
31    clippy::match_single_binding,
32    clippy::single_match
33)]
34const _: () = {
35    use miniserde::de::{Map, Visitor};
36    use miniserde::json::Value;
37    use miniserde::{Deserialize, Result, make_place};
38    use stripe_types::miniserde_helpers::FromValueOpt;
39    use stripe_types::{MapBuilder, ObjectDeser};
40
41    make_place!(Place);
42
43    impl Deserialize for SetupIntentNextActionVerifyWithMicrodeposits {
44        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
45            Place::new(out)
46        }
47    }
48
49    struct Builder<'a> {
50        out: &'a mut Option<SetupIntentNextActionVerifyWithMicrodeposits>,
51        builder: SetupIntentNextActionVerifyWithMicrodepositsBuilder,
52    }
53
54    impl Visitor for Place<SetupIntentNextActionVerifyWithMicrodeposits> {
55        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
56            Ok(Box::new(Builder {
57                out: &mut self.out,
58                builder: SetupIntentNextActionVerifyWithMicrodepositsBuilder::deser_default(),
59            }))
60        }
61    }
62
63    impl MapBuilder for SetupIntentNextActionVerifyWithMicrodepositsBuilder {
64        type Out = SetupIntentNextActionVerifyWithMicrodeposits;
65        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
66            Ok(match k {
67                "arrival_date" => Deserialize::begin(&mut self.arrival_date),
68                "hosted_verification_url" => Deserialize::begin(&mut self.hosted_verification_url),
69                "microdeposit_type" => Deserialize::begin(&mut self.microdeposit_type),
70                _ => <dyn Visitor>::ignore(),
71            })
72        }
73
74        fn deser_default() -> Self {
75            Self {
76                arrival_date: None,
77                hosted_verification_url: None,
78                microdeposit_type: Some(None),
79            }
80        }
81
82        fn take_out(&mut self) -> Option<Self::Out> {
83            let (Some(arrival_date), Some(hosted_verification_url), Some(microdeposit_type)) = (
84                self.arrival_date,
85                self.hosted_verification_url.take(),
86                self.microdeposit_type.take(),
87            ) else {
88                return None;
89            };
90            Some(Self::Out { arrival_date, hosted_verification_url, microdeposit_type })
91        }
92    }
93
94    impl Map for Builder<'_> {
95        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
96            self.builder.key(k)
97        }
98
99        fn finish(&mut self) -> Result<()> {
100            *self.out = self.builder.take_out();
101            Ok(())
102        }
103    }
104
105    impl ObjectDeser for SetupIntentNextActionVerifyWithMicrodeposits {
106        type Builder = SetupIntentNextActionVerifyWithMicrodepositsBuilder;
107    }
108
109    impl FromValueOpt for SetupIntentNextActionVerifyWithMicrodeposits {
110        fn from_value(v: Value) -> Option<Self> {
111            let Value::Object(obj) = v else {
112                return None;
113            };
114            let mut b = SetupIntentNextActionVerifyWithMicrodepositsBuilder::deser_default();
115            for (k, v) in obj {
116                match k.as_str() {
117                    "arrival_date" => b.arrival_date = FromValueOpt::from_value(v),
118                    "hosted_verification_url" => {
119                        b.hosted_verification_url = FromValueOpt::from_value(v)
120                    }
121                    "microdeposit_type" => b.microdeposit_type = FromValueOpt::from_value(v),
122                    _ => {}
123                }
124            }
125            b.take_out()
126        }
127    }
128};
129/// The type of the microdeposit sent to the customer.
130/// Used to distinguish between different verification methods.
131#[derive(Clone, Eq, PartialEq)]
132#[non_exhaustive]
133pub enum SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType {
134    Amounts,
135    DescriptorCode,
136    /// An unrecognized value from Stripe. Should not be used as a request parameter.
137    Unknown(String),
138}
139impl SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType {
140    pub fn as_str(&self) -> &str {
141        use SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType::*;
142        match self {
143            Amounts => "amounts",
144            DescriptorCode => "descriptor_code",
145            Unknown(v) => v,
146        }
147    }
148}
149
150impl std::str::FromStr for SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType {
151    type Err = std::convert::Infallible;
152    fn from_str(s: &str) -> Result<Self, Self::Err> {
153        use SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType::*;
154        match s {
155            "amounts" => Ok(Amounts),
156            "descriptor_code" => Ok(DescriptorCode),
157            v => {
158                tracing::warn!(
159                    "Unknown value '{}' for enum '{}'",
160                    v,
161                    "SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType"
162                );
163                Ok(Unknown(v.to_owned()))
164            }
165        }
166    }
167}
168impl std::fmt::Display for SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType {
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 SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType {
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 SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType {
182    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
183        f.debug_struct(stringify!(SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType))
184            .finish_non_exhaustive()
185    }
186}
187#[cfg(feature = "serialize")]
188impl serde::Serialize for SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType {
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 SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType {
197    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
198        crate::Place::new(out)
199    }
200}
201
202impl miniserde::de::Visitor
203    for crate::Place<SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType>
204{
205    fn string(&mut self, s: &str) -> miniserde::Result<()> {
206        use std::str::FromStr;
207        self.out = Some(
208            SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType::from_str(s)
209                .expect("infallible"),
210        );
211        Ok(())
212    }
213}
214
215stripe_types::impl_from_val_with_from_str!(
216    SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType
217);
218#[cfg(feature = "deserialize")]
219impl<'de> serde::Deserialize<'de> for SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType {
220    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
221        use std::str::FromStr;
222        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
223        Ok(Self::from_str(&s).expect("infallible"))
224    }
225}