stripe_shared/
setup_intent_payment_method_options_acss_debit.rs1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct SetupIntentPaymentMethodOptionsAcssDebit {
5 pub currency: Option<SetupIntentPaymentMethodOptionsAcssDebitCurrency>,
7 pub mandate_options:
8 Option<stripe_shared::SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit>,
9 pub verification_method: Option<SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod>,
11}
12#[doc(hidden)]
13pub struct SetupIntentPaymentMethodOptionsAcssDebitBuilder {
14 currency: Option<Option<SetupIntentPaymentMethodOptionsAcssDebitCurrency>>,
15 mandate_options:
16 Option<Option<stripe_shared::SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit>>,
17 verification_method: Option<Option<SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod>>,
18}
19
20#[allow(
21 unused_variables,
22 irrefutable_let_patterns,
23 clippy::let_unit_value,
24 clippy::match_single_binding,
25 clippy::single_match
26)]
27const _: () = {
28 use miniserde::de::{Map, Visitor};
29 use miniserde::json::Value;
30 use miniserde::{make_place, Deserialize, Result};
31 use stripe_types::miniserde_helpers::FromValueOpt;
32 use stripe_types::{MapBuilder, ObjectDeser};
33
34 make_place!(Place);
35
36 impl Deserialize for SetupIntentPaymentMethodOptionsAcssDebit {
37 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
38 Place::new(out)
39 }
40 }
41
42 struct Builder<'a> {
43 out: &'a mut Option<SetupIntentPaymentMethodOptionsAcssDebit>,
44 builder: SetupIntentPaymentMethodOptionsAcssDebitBuilder,
45 }
46
47 impl Visitor for Place<SetupIntentPaymentMethodOptionsAcssDebit> {
48 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
49 Ok(Box::new(Builder {
50 out: &mut self.out,
51 builder: SetupIntentPaymentMethodOptionsAcssDebitBuilder::deser_default(),
52 }))
53 }
54 }
55
56 impl MapBuilder for SetupIntentPaymentMethodOptionsAcssDebitBuilder {
57 type Out = SetupIntentPaymentMethodOptionsAcssDebit;
58 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
59 Ok(match k {
60 "currency" => Deserialize::begin(&mut self.currency),
61 "mandate_options" => Deserialize::begin(&mut self.mandate_options),
62 "verification_method" => Deserialize::begin(&mut self.verification_method),
63
64 _ => <dyn Visitor>::ignore(),
65 })
66 }
67
68 fn deser_default() -> Self {
69 Self {
70 currency: Deserialize::default(),
71 mandate_options: Deserialize::default(),
72 verification_method: Deserialize::default(),
73 }
74 }
75
76 fn take_out(&mut self) -> Option<Self::Out> {
77 let (Some(currency), Some(mandate_options), Some(verification_method)) =
78 (self.currency, self.mandate_options.take(), self.verification_method)
79 else {
80 return None;
81 };
82 Some(Self::Out { currency, mandate_options, verification_method })
83 }
84 }
85
86 impl<'a> Map for Builder<'a> {
87 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
88 self.builder.key(k)
89 }
90
91 fn finish(&mut self) -> Result<()> {
92 *self.out = self.builder.take_out();
93 Ok(())
94 }
95 }
96
97 impl ObjectDeser for SetupIntentPaymentMethodOptionsAcssDebit {
98 type Builder = SetupIntentPaymentMethodOptionsAcssDebitBuilder;
99 }
100
101 impl FromValueOpt for SetupIntentPaymentMethodOptionsAcssDebit {
102 fn from_value(v: Value) -> Option<Self> {
103 let Value::Object(obj) = v else {
104 return None;
105 };
106 let mut b = SetupIntentPaymentMethodOptionsAcssDebitBuilder::deser_default();
107 for (k, v) in obj {
108 match k.as_str() {
109 "currency" => b.currency = FromValueOpt::from_value(v),
110 "mandate_options" => b.mandate_options = FromValueOpt::from_value(v),
111 "verification_method" => b.verification_method = FromValueOpt::from_value(v),
112
113 _ => {}
114 }
115 }
116 b.take_out()
117 }
118 }
119};
120#[derive(Copy, Clone, Eq, PartialEq)]
122pub enum SetupIntentPaymentMethodOptionsAcssDebitCurrency {
123 Cad,
124 Usd,
125}
126impl SetupIntentPaymentMethodOptionsAcssDebitCurrency {
127 pub fn as_str(self) -> &'static str {
128 use SetupIntentPaymentMethodOptionsAcssDebitCurrency::*;
129 match self {
130 Cad => "cad",
131 Usd => "usd",
132 }
133 }
134}
135
136impl std::str::FromStr for SetupIntentPaymentMethodOptionsAcssDebitCurrency {
137 type Err = stripe_types::StripeParseError;
138 fn from_str(s: &str) -> Result<Self, Self::Err> {
139 use SetupIntentPaymentMethodOptionsAcssDebitCurrency::*;
140 match s {
141 "cad" => Ok(Cad),
142 "usd" => Ok(Usd),
143 _ => Err(stripe_types::StripeParseError),
144 }
145 }
146}
147impl std::fmt::Display for SetupIntentPaymentMethodOptionsAcssDebitCurrency {
148 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
149 f.write_str(self.as_str())
150 }
151}
152
153impl std::fmt::Debug for SetupIntentPaymentMethodOptionsAcssDebitCurrency {
154 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
155 f.write_str(self.as_str())
156 }
157}
158#[cfg(feature = "serialize")]
159impl serde::Serialize for SetupIntentPaymentMethodOptionsAcssDebitCurrency {
160 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
161 where
162 S: serde::Serializer,
163 {
164 serializer.serialize_str(self.as_str())
165 }
166}
167impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsAcssDebitCurrency {
168 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
169 crate::Place::new(out)
170 }
171}
172
173impl miniserde::de::Visitor for crate::Place<SetupIntentPaymentMethodOptionsAcssDebitCurrency> {
174 fn string(&mut self, s: &str) -> miniserde::Result<()> {
175 use std::str::FromStr;
176 self.out = Some(
177 SetupIntentPaymentMethodOptionsAcssDebitCurrency::from_str(s)
178 .map_err(|_| miniserde::Error)?,
179 );
180 Ok(())
181 }
182}
183
184stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsAcssDebitCurrency);
185#[cfg(feature = "deserialize")]
186impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsAcssDebitCurrency {
187 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
188 use std::str::FromStr;
189 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
190 Self::from_str(&s).map_err(|_| {
191 serde::de::Error::custom(
192 "Unknown value for SetupIntentPaymentMethodOptionsAcssDebitCurrency",
193 )
194 })
195 }
196}
197#[derive(Copy, Clone, Eq, PartialEq)]
199pub enum SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod {
200 Automatic,
201 Instant,
202 Microdeposits,
203}
204impl SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod {
205 pub fn as_str(self) -> &'static str {
206 use SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod::*;
207 match self {
208 Automatic => "automatic",
209 Instant => "instant",
210 Microdeposits => "microdeposits",
211 }
212 }
213}
214
215impl std::str::FromStr for SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod {
216 type Err = stripe_types::StripeParseError;
217 fn from_str(s: &str) -> Result<Self, Self::Err> {
218 use SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod::*;
219 match s {
220 "automatic" => Ok(Automatic),
221 "instant" => Ok(Instant),
222 "microdeposits" => Ok(Microdeposits),
223 _ => Err(stripe_types::StripeParseError),
224 }
225 }
226}
227impl std::fmt::Display for SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod {
228 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
229 f.write_str(self.as_str())
230 }
231}
232
233impl std::fmt::Debug for SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod {
234 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
235 f.write_str(self.as_str())
236 }
237}
238#[cfg(feature = "serialize")]
239impl serde::Serialize for SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod {
240 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
241 where
242 S: serde::Serializer,
243 {
244 serializer.serialize_str(self.as_str())
245 }
246}
247impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod {
248 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
249 crate::Place::new(out)
250 }
251}
252
253impl miniserde::de::Visitor
254 for crate::Place<SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod>
255{
256 fn string(&mut self, s: &str) -> miniserde::Result<()> {
257 use std::str::FromStr;
258 self.out = Some(
259 SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod::from_str(s)
260 .map_err(|_| miniserde::Error)?,
261 );
262 Ok(())
263 }
264}
265
266stripe_types::impl_from_val_with_from_str!(
267 SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod
268);
269#[cfg(feature = "deserialize")]
270impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod {
271 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
272 use std::str::FromStr;
273 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
274 Self::from_str(&s).map_err(|_| {
275 serde::de::Error::custom(
276 "Unknown value for SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod",
277 )
278 })
279 }
280}