stripe_shared/
setup_intent_payment_method_options_us_bank_account.rs1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct SetupIntentPaymentMethodOptionsUsBankAccount {
5 pub financial_connections: Option<stripe_shared::LinkedAccountOptionsCommon>,
6 pub mandate_options: Option<stripe_shared::PaymentMethodOptionsUsBankAccountMandateOptions>,
7 pub verification_method: Option<SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod>,
9}
10#[doc(hidden)]
11pub struct SetupIntentPaymentMethodOptionsUsBankAccountBuilder {
12 financial_connections: Option<Option<stripe_shared::LinkedAccountOptionsCommon>>,
13 mandate_options: Option<Option<stripe_shared::PaymentMethodOptionsUsBankAccountMandateOptions>>,
14 verification_method:
15 Option<Option<SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod>>,
16}
17
18#[allow(
19 unused_variables,
20 irrefutable_let_patterns,
21 clippy::let_unit_value,
22 clippy::match_single_binding,
23 clippy::single_match
24)]
25const _: () = {
26 use miniserde::de::{Map, Visitor};
27 use miniserde::json::Value;
28 use miniserde::{Deserialize, Result, make_place};
29 use stripe_types::miniserde_helpers::FromValueOpt;
30 use stripe_types::{MapBuilder, ObjectDeser};
31
32 make_place!(Place);
33
34 impl Deserialize for SetupIntentPaymentMethodOptionsUsBankAccount {
35 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
36 Place::new(out)
37 }
38 }
39
40 struct Builder<'a> {
41 out: &'a mut Option<SetupIntentPaymentMethodOptionsUsBankAccount>,
42 builder: SetupIntentPaymentMethodOptionsUsBankAccountBuilder,
43 }
44
45 impl Visitor for Place<SetupIntentPaymentMethodOptionsUsBankAccount> {
46 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
47 Ok(Box::new(Builder {
48 out: &mut self.out,
49 builder: SetupIntentPaymentMethodOptionsUsBankAccountBuilder::deser_default(),
50 }))
51 }
52 }
53
54 impl MapBuilder for SetupIntentPaymentMethodOptionsUsBankAccountBuilder {
55 type Out = SetupIntentPaymentMethodOptionsUsBankAccount;
56 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
57 Ok(match k {
58 "financial_connections" => Deserialize::begin(&mut self.financial_connections),
59 "mandate_options" => Deserialize::begin(&mut self.mandate_options),
60 "verification_method" => Deserialize::begin(&mut self.verification_method),
61
62 _ => <dyn Visitor>::ignore(),
63 })
64 }
65
66 fn deser_default() -> Self {
67 Self {
68 financial_connections: Deserialize::default(),
69 mandate_options: Deserialize::default(),
70 verification_method: Deserialize::default(),
71 }
72 }
73
74 fn take_out(&mut self) -> Option<Self::Out> {
75 let (Some(financial_connections), Some(mandate_options), Some(verification_method)) =
76 (self.financial_connections.take(), self.mandate_options, self.verification_method)
77 else {
78 return None;
79 };
80 Some(Self::Out { financial_connections, mandate_options, verification_method })
81 }
82 }
83
84 impl Map for Builder<'_> {
85 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
86 self.builder.key(k)
87 }
88
89 fn finish(&mut self) -> Result<()> {
90 *self.out = self.builder.take_out();
91 Ok(())
92 }
93 }
94
95 impl ObjectDeser for SetupIntentPaymentMethodOptionsUsBankAccount {
96 type Builder = SetupIntentPaymentMethodOptionsUsBankAccountBuilder;
97 }
98
99 impl FromValueOpt for SetupIntentPaymentMethodOptionsUsBankAccount {
100 fn from_value(v: Value) -> Option<Self> {
101 let Value::Object(obj) = v else {
102 return None;
103 };
104 let mut b = SetupIntentPaymentMethodOptionsUsBankAccountBuilder::deser_default();
105 for (k, v) in obj {
106 match k.as_str() {
107 "financial_connections" => {
108 b.financial_connections = FromValueOpt::from_value(v)
109 }
110 "mandate_options" => b.mandate_options = FromValueOpt::from_value(v),
111 "verification_method" => b.verification_method = FromValueOpt::from_value(v),
112
113 _ => {}
114 }
115 }
116 b.take_out()
117 }
118 }
119};
120#[derive(Copy, Clone, Eq, PartialEq)]
122pub enum SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
123 Automatic,
124 Instant,
125 Microdeposits,
126}
127impl SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
128 pub fn as_str(self) -> &'static str {
129 use SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod::*;
130 match self {
131 Automatic => "automatic",
132 Instant => "instant",
133 Microdeposits => "microdeposits",
134 }
135 }
136}
137
138impl std::str::FromStr for SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
139 type Err = stripe_types::StripeParseError;
140 fn from_str(s: &str) -> Result<Self, Self::Err> {
141 use SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod::*;
142 match s {
143 "automatic" => Ok(Automatic),
144 "instant" => Ok(Instant),
145 "microdeposits" => Ok(Microdeposits),
146 _ => Err(stripe_types::StripeParseError),
147 }
148 }
149}
150impl std::fmt::Display for SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
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 SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
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 SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
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 SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
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<SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod>
178{
179 fn string(&mut self, s: &str) -> miniserde::Result<()> {
180 use std::str::FromStr;
181 self.out = Some(
182 SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod::from_str(s)
183 .map_err(|_| miniserde::Error)?,
184 );
185 Ok(())
186 }
187}
188
189stripe_types::impl_from_val_with_from_str!(
190 SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod
191);
192#[cfg(feature = "deserialize")]
193impl<'de> serde::Deserialize<'de>
194 for SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod
195{
196 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
197 use std::str::FromStr;
198 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
199 Self::from_str(&s).map_err(|_| {
200 serde::de::Error::custom(
201 "Unknown value for SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod",
202 )
203 })
204 }
205}