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 _ => <dyn Visitor>::ignore(),
62 })
63 }
64
65 fn deser_default() -> Self {
66 Self {
67 financial_connections: Deserialize::default(),
68 mandate_options: Deserialize::default(),
69 verification_method: Deserialize::default(),
70 }
71 }
72
73 fn take_out(&mut self) -> Option<Self::Out> {
74 let (Some(financial_connections), Some(mandate_options), Some(verification_method)) = (
75 self.financial_connections.take(),
76 self.mandate_options.take(),
77 self.verification_method.take(),
78 ) else {
79 return None;
80 };
81 Some(Self::Out { financial_connections, mandate_options, verification_method })
82 }
83 }
84
85 impl Map for Builder<'_> {
86 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
87 self.builder.key(k)
88 }
89
90 fn finish(&mut self) -> Result<()> {
91 *self.out = self.builder.take_out();
92 Ok(())
93 }
94 }
95
96 impl ObjectDeser for SetupIntentPaymentMethodOptionsUsBankAccount {
97 type Builder = SetupIntentPaymentMethodOptionsUsBankAccountBuilder;
98 }
99
100 impl FromValueOpt for SetupIntentPaymentMethodOptionsUsBankAccount {
101 fn from_value(v: Value) -> Option<Self> {
102 let Value::Object(obj) = v else {
103 return None;
104 };
105 let mut b = SetupIntentPaymentMethodOptionsUsBankAccountBuilder::deser_default();
106 for (k, v) in obj {
107 match k.as_str() {
108 "financial_connections" => {
109 b.financial_connections = FromValueOpt::from_value(v)
110 }
111 "mandate_options" => b.mandate_options = FromValueOpt::from_value(v),
112 "verification_method" => b.verification_method = FromValueOpt::from_value(v),
113 _ => {}
114 }
115 }
116 b.take_out()
117 }
118 }
119};
120#[derive(Clone, Eq, PartialEq)]
122#[non_exhaustive]
123pub enum SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
124 Automatic,
125 Instant,
126 Microdeposits,
127 Unknown(String),
129}
130impl SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
131 pub fn as_str(&self) -> &str {
132 use SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod::*;
133 match self {
134 Automatic => "automatic",
135 Instant => "instant",
136 Microdeposits => "microdeposits",
137 Unknown(v) => v,
138 }
139 }
140}
141
142impl std::str::FromStr for SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
143 type Err = std::convert::Infallible;
144 fn from_str(s: &str) -> Result<Self, Self::Err> {
145 use SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod::*;
146 match s {
147 "automatic" => Ok(Automatic),
148 "instant" => Ok(Instant),
149 "microdeposits" => Ok(Microdeposits),
150 v => {
151 tracing::warn!(
152 "Unknown value '{}' for enum '{}'",
153 v,
154 "SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod"
155 );
156 Ok(Unknown(v.to_owned()))
157 }
158 }
159 }
160}
161impl std::fmt::Display for SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
162 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
163 f.write_str(self.as_str())
164 }
165}
166
167impl std::fmt::Debug for SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
168 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
169 f.write_str(self.as_str())
170 }
171}
172#[cfg(feature = "serialize")]
173impl serde::Serialize for SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
174 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
175 where
176 S: serde::Serializer,
177 {
178 serializer.serialize_str(self.as_str())
179 }
180}
181impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
182 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
183 crate::Place::new(out)
184 }
185}
186
187impl miniserde::de::Visitor
188 for crate::Place<SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod>
189{
190 fn string(&mut self, s: &str) -> miniserde::Result<()> {
191 use std::str::FromStr;
192 self.out = Some(
193 SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod::from_str(s)
194 .expect("infallible"),
195 );
196 Ok(())
197 }
198}
199
200stripe_types::impl_from_val_with_from_str!(
201 SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod
202);
203#[cfg(feature = "deserialize")]
204impl<'de> serde::Deserialize<'de>
205 for SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod
206{
207 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
208 use std::str::FromStr;
209 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
210 Ok(Self::from_str(&s).expect("infallible"))
211 }
212}