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