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