stripe_shared/
setup_intent_next_action_verify_with_microdeposits.rs

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