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