1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit {
5 pub custom_mandate_url: Option<String>,
7 pub interval_description: Option<String>,
10 pub payment_schedule:
12 Option<PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule>,
13 pub transaction_type:
15 Option<PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType>,
16}
17#[doc(hidden)]
18pub struct PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder {
19 custom_mandate_url: Option<Option<String>>,
20 interval_description: Option<Option<String>>,
21 payment_schedule:
22 Option<Option<PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule>>,
23 transaction_type:
24 Option<Option<PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType>>,
25}
26
27#[allow(
28 unused_variables,
29 irrefutable_let_patterns,
30 clippy::let_unit_value,
31 clippy::match_single_binding,
32 clippy::single_match
33)]
34const _: () = {
35 use miniserde::de::{Map, Visitor};
36 use miniserde::json::Value;
37 use miniserde::{Deserialize, Result, make_place};
38 use stripe_types::miniserde_helpers::FromValueOpt;
39 use stripe_types::{MapBuilder, ObjectDeser};
40
41 make_place!(Place);
42
43 impl Deserialize for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit {
44 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
45 Place::new(out)
46 }
47 }
48
49 struct Builder<'a> {
50 out: &'a mut Option<PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit>,
51 builder: PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder,
52 }
53
54 impl Visitor for Place<PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit> {
55 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
56 Ok(Box::new(Builder {
57 out: &mut self.out,
58 builder:
59 PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder::deser_default(),
60 }))
61 }
62 }
63
64 impl MapBuilder for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder {
65 type Out = PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit;
66 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
67 Ok(match k {
68 "custom_mandate_url" => Deserialize::begin(&mut self.custom_mandate_url),
69 "interval_description" => Deserialize::begin(&mut self.interval_description),
70 "payment_schedule" => Deserialize::begin(&mut self.payment_schedule),
71 "transaction_type" => Deserialize::begin(&mut self.transaction_type),
72 _ => <dyn Visitor>::ignore(),
73 })
74 }
75
76 fn deser_default() -> Self {
77 Self {
78 custom_mandate_url: Deserialize::default(),
79 interval_description: Deserialize::default(),
80 payment_schedule: Deserialize::default(),
81 transaction_type: Deserialize::default(),
82 }
83 }
84
85 fn take_out(&mut self) -> Option<Self::Out> {
86 let (
87 Some(custom_mandate_url),
88 Some(interval_description),
89 Some(payment_schedule),
90 Some(transaction_type),
91 ) = (
92 self.custom_mandate_url.take(),
93 self.interval_description.take(),
94 self.payment_schedule.take(),
95 self.transaction_type.take(),
96 )
97 else {
98 return None;
99 };
100 Some(Self::Out {
101 custom_mandate_url,
102 interval_description,
103 payment_schedule,
104 transaction_type,
105 })
106 }
107 }
108
109 impl Map for Builder<'_> {
110 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
111 self.builder.key(k)
112 }
113
114 fn finish(&mut self) -> Result<()> {
115 *self.out = self.builder.take_out();
116 Ok(())
117 }
118 }
119
120 impl ObjectDeser for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit {
121 type Builder = PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder;
122 }
123
124 impl FromValueOpt for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit {
125 fn from_value(v: Value) -> Option<Self> {
126 let Value::Object(obj) = v else {
127 return None;
128 };
129 let mut b =
130 PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder::deser_default();
131 for (k, v) in obj {
132 match k.as_str() {
133 "custom_mandate_url" => b.custom_mandate_url = FromValueOpt::from_value(v),
134 "interval_description" => b.interval_description = FromValueOpt::from_value(v),
135 "payment_schedule" => b.payment_schedule = FromValueOpt::from_value(v),
136 "transaction_type" => b.transaction_type = FromValueOpt::from_value(v),
137 _ => {}
138 }
139 }
140 b.take_out()
141 }
142 }
143};
144#[derive(Clone, Eq, PartialEq)]
146#[non_exhaustive]
147pub enum PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
148 Combined,
149 Interval,
150 Sporadic,
151 Unknown(String),
153}
154impl PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
155 pub fn as_str(&self) -> &str {
156 use PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule::*;
157 match self {
158 Combined => "combined",
159 Interval => "interval",
160 Sporadic => "sporadic",
161 Unknown(v) => v,
162 }
163 }
164}
165
166impl std::str::FromStr for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
167 type Err = std::convert::Infallible;
168 fn from_str(s: &str) -> Result<Self, Self::Err> {
169 use PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule::*;
170 match s {
171 "combined" => Ok(Combined),
172 "interval" => Ok(Interval),
173 "sporadic" => Ok(Sporadic),
174 v => {
175 tracing::warn!(
176 "Unknown value '{}' for enum '{}'",
177 v,
178 "PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule"
179 );
180 Ok(Unknown(v.to_owned()))
181 }
182 }
183 }
184}
185impl std::fmt::Display for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
186 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
187 f.write_str(self.as_str())
188 }
189}
190
191impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
192 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
193 f.write_str(self.as_str())
194 }
195}
196#[cfg(feature = "serialize")]
197impl serde::Serialize for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule {
198 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
199 where
200 S: serde::Serializer,
201 {
202 serializer.serialize_str(self.as_str())
203 }
204}
205impl miniserde::Deserialize
206 for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule
207{
208 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
209 crate::Place::new(out)
210 }
211}
212
213impl miniserde::de::Visitor
214 for crate::Place<PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule>
215{
216 fn string(&mut self, s: &str) -> miniserde::Result<()> {
217 use std::str::FromStr;
218 self.out = Some(
219 PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule::from_str(s)
220 .expect("infallible"),
221 );
222 Ok(())
223 }
224}
225
226stripe_types::impl_from_val_with_from_str!(
227 PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule
228);
229#[cfg(feature = "deserialize")]
230impl<'de> serde::Deserialize<'de>
231 for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule
232{
233 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
234 use std::str::FromStr;
235 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
236 Ok(Self::from_str(&s).expect("infallible"))
237 }
238}
239#[derive(Clone, Eq, PartialEq)]
241#[non_exhaustive]
242pub enum PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
243 Business,
244 Personal,
245 Unknown(String),
247}
248impl PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
249 pub fn as_str(&self) -> &str {
250 use PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType::*;
251 match self {
252 Business => "business",
253 Personal => "personal",
254 Unknown(v) => v,
255 }
256 }
257}
258
259impl std::str::FromStr for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
260 type Err = std::convert::Infallible;
261 fn from_str(s: &str) -> Result<Self, Self::Err> {
262 use PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType::*;
263 match s {
264 "business" => Ok(Business),
265 "personal" => Ok(Personal),
266 v => {
267 tracing::warn!(
268 "Unknown value '{}' for enum '{}'",
269 v,
270 "PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType"
271 );
272 Ok(Unknown(v.to_owned()))
273 }
274 }
275 }
276}
277impl std::fmt::Display for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
278 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
279 f.write_str(self.as_str())
280 }
281}
282
283impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
284 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
285 f.write_str(self.as_str())
286 }
287}
288#[cfg(feature = "serialize")]
289impl serde::Serialize for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType {
290 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
291 where
292 S: serde::Serializer,
293 {
294 serializer.serialize_str(self.as_str())
295 }
296}
297impl miniserde::Deserialize
298 for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType
299{
300 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
301 crate::Place::new(out)
302 }
303}
304
305impl miniserde::de::Visitor
306 for crate::Place<PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType>
307{
308 fn string(&mut self, s: &str) -> miniserde::Result<()> {
309 use std::str::FromStr;
310 self.out = Some(
311 PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType::from_str(s)
312 .expect("infallible"),
313 );
314 Ok(())
315 }
316}
317
318stripe_types::impl_from_val_with_from_str!(
319 PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType
320);
321#[cfg(feature = "deserialize")]
322impl<'de> serde::Deserialize<'de>
323 for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType
324{
325 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
326 use std::str::FromStr;
327 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
328 Ok(Self::from_str(&s).expect("infallible"))
329 }
330}