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