1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct CheckoutAcssDebitMandateOptions {
5 pub custom_mandate_url: Option<String>,
7 pub default_for: Option<Vec<CheckoutAcssDebitMandateOptionsDefaultFor>>,
10 pub interval_description: Option<String>,
13 pub payment_schedule: Option<CheckoutAcssDebitMandateOptionsPaymentSchedule>,
15 pub transaction_type: Option<CheckoutAcssDebitMandateOptionsTransactionType>,
17}
18#[doc(hidden)]
19pub struct CheckoutAcssDebitMandateOptionsBuilder {
20 custom_mandate_url: Option<Option<String>>,
21 default_for: Option<Option<Vec<CheckoutAcssDebitMandateOptionsDefaultFor>>>,
22 interval_description: Option<Option<String>>,
23 payment_schedule: Option<Option<CheckoutAcssDebitMandateOptionsPaymentSchedule>>,
24 transaction_type: Option<Option<CheckoutAcssDebitMandateOptionsTransactionType>>,
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 CheckoutAcssDebitMandateOptions {
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<CheckoutAcssDebitMandateOptions>,
51 builder: CheckoutAcssDebitMandateOptionsBuilder,
52 }
53
54 impl Visitor for Place<CheckoutAcssDebitMandateOptions> {
55 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
56 Ok(Box::new(Builder {
57 out: &mut self.out,
58 builder: CheckoutAcssDebitMandateOptionsBuilder::deser_default(),
59 }))
60 }
61 }
62
63 impl MapBuilder for CheckoutAcssDebitMandateOptionsBuilder {
64 type Out = CheckoutAcssDebitMandateOptions;
65 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
66 Ok(match k {
67 "custom_mandate_url" => Deserialize::begin(&mut self.custom_mandate_url),
68 "default_for" => Deserialize::begin(&mut self.default_for),
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 default_for: Deserialize::default(),
80 interval_description: Deserialize::default(),
81 payment_schedule: Deserialize::default(),
82 transaction_type: Deserialize::default(),
83 }
84 }
85
86 fn take_out(&mut self) -> Option<Self::Out> {
87 let (
88 Some(custom_mandate_url),
89 Some(default_for),
90 Some(interval_description),
91 Some(payment_schedule),
92 Some(transaction_type),
93 ) = (
94 self.custom_mandate_url.take(),
95 self.default_for.take(),
96 self.interval_description.take(),
97 self.payment_schedule.take(),
98 self.transaction_type.take(),
99 )
100 else {
101 return None;
102 };
103 Some(Self::Out {
104 custom_mandate_url,
105 default_for,
106 interval_description,
107 payment_schedule,
108 transaction_type,
109 })
110 }
111 }
112
113 impl Map for Builder<'_> {
114 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
115 self.builder.key(k)
116 }
117
118 fn finish(&mut self) -> Result<()> {
119 *self.out = self.builder.take_out();
120 Ok(())
121 }
122 }
123
124 impl ObjectDeser for CheckoutAcssDebitMandateOptions {
125 type Builder = CheckoutAcssDebitMandateOptionsBuilder;
126 }
127
128 impl FromValueOpt for CheckoutAcssDebitMandateOptions {
129 fn from_value(v: Value) -> Option<Self> {
130 let Value::Object(obj) = v else {
131 return None;
132 };
133 let mut b = CheckoutAcssDebitMandateOptionsBuilder::deser_default();
134 for (k, v) in obj {
135 match k.as_str() {
136 "custom_mandate_url" => b.custom_mandate_url = FromValueOpt::from_value(v),
137 "default_for" => b.default_for = FromValueOpt::from_value(v),
138 "interval_description" => b.interval_description = FromValueOpt::from_value(v),
139 "payment_schedule" => b.payment_schedule = FromValueOpt::from_value(v),
140 "transaction_type" => b.transaction_type = FromValueOpt::from_value(v),
141 _ => {}
142 }
143 }
144 b.take_out()
145 }
146 }
147};
148#[derive(Clone, Eq, PartialEq)]
151#[non_exhaustive]
152pub enum CheckoutAcssDebitMandateOptionsDefaultFor {
153 Invoice,
154 Subscription,
155 Unknown(String),
157}
158impl CheckoutAcssDebitMandateOptionsDefaultFor {
159 pub fn as_str(&self) -> &str {
160 use CheckoutAcssDebitMandateOptionsDefaultFor::*;
161 match self {
162 Invoice => "invoice",
163 Subscription => "subscription",
164 Unknown(v) => v,
165 }
166 }
167}
168
169impl std::str::FromStr for CheckoutAcssDebitMandateOptionsDefaultFor {
170 type Err = std::convert::Infallible;
171 fn from_str(s: &str) -> Result<Self, Self::Err> {
172 use CheckoutAcssDebitMandateOptionsDefaultFor::*;
173 match s {
174 "invoice" => Ok(Invoice),
175 "subscription" => Ok(Subscription),
176 v => {
177 tracing::warn!(
178 "Unknown value '{}' for enum '{}'",
179 v,
180 "CheckoutAcssDebitMandateOptionsDefaultFor"
181 );
182 Ok(Unknown(v.to_owned()))
183 }
184 }
185 }
186}
187impl std::fmt::Display for CheckoutAcssDebitMandateOptionsDefaultFor {
188 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
189 f.write_str(self.as_str())
190 }
191}
192
193impl std::fmt::Debug for CheckoutAcssDebitMandateOptionsDefaultFor {
194 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
195 f.write_str(self.as_str())
196 }
197}
198#[cfg(feature = "serialize")]
199impl serde::Serialize for CheckoutAcssDebitMandateOptionsDefaultFor {
200 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
201 where
202 S: serde::Serializer,
203 {
204 serializer.serialize_str(self.as_str())
205 }
206}
207impl miniserde::Deserialize for CheckoutAcssDebitMandateOptionsDefaultFor {
208 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
209 crate::Place::new(out)
210 }
211}
212
213impl miniserde::de::Visitor for crate::Place<CheckoutAcssDebitMandateOptionsDefaultFor> {
214 fn string(&mut self, s: &str) -> miniserde::Result<()> {
215 use std::str::FromStr;
216 self.out =
217 Some(CheckoutAcssDebitMandateOptionsDefaultFor::from_str(s).expect("infallible"));
218 Ok(())
219 }
220}
221
222stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitMandateOptionsDefaultFor);
223#[cfg(feature = "deserialize")]
224impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitMandateOptionsDefaultFor {
225 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
226 use std::str::FromStr;
227 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
228 Ok(Self::from_str(&s).expect("infallible"))
229 }
230}
231#[derive(Clone, Eq, PartialEq)]
233#[non_exhaustive]
234pub enum CheckoutAcssDebitMandateOptionsPaymentSchedule {
235 Combined,
236 Interval,
237 Sporadic,
238 Unknown(String),
240}
241impl CheckoutAcssDebitMandateOptionsPaymentSchedule {
242 pub fn as_str(&self) -> &str {
243 use CheckoutAcssDebitMandateOptionsPaymentSchedule::*;
244 match self {
245 Combined => "combined",
246 Interval => "interval",
247 Sporadic => "sporadic",
248 Unknown(v) => v,
249 }
250 }
251}
252
253impl std::str::FromStr for CheckoutAcssDebitMandateOptionsPaymentSchedule {
254 type Err = std::convert::Infallible;
255 fn from_str(s: &str) -> Result<Self, Self::Err> {
256 use CheckoutAcssDebitMandateOptionsPaymentSchedule::*;
257 match s {
258 "combined" => Ok(Combined),
259 "interval" => Ok(Interval),
260 "sporadic" => Ok(Sporadic),
261 v => {
262 tracing::warn!(
263 "Unknown value '{}' for enum '{}'",
264 v,
265 "CheckoutAcssDebitMandateOptionsPaymentSchedule"
266 );
267 Ok(Unknown(v.to_owned()))
268 }
269 }
270 }
271}
272impl std::fmt::Display for CheckoutAcssDebitMandateOptionsPaymentSchedule {
273 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
274 f.write_str(self.as_str())
275 }
276}
277
278impl std::fmt::Debug for CheckoutAcssDebitMandateOptionsPaymentSchedule {
279 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
280 f.write_str(self.as_str())
281 }
282}
283#[cfg(feature = "serialize")]
284impl serde::Serialize for CheckoutAcssDebitMandateOptionsPaymentSchedule {
285 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
286 where
287 S: serde::Serializer,
288 {
289 serializer.serialize_str(self.as_str())
290 }
291}
292impl miniserde::Deserialize for CheckoutAcssDebitMandateOptionsPaymentSchedule {
293 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
294 crate::Place::new(out)
295 }
296}
297
298impl miniserde::de::Visitor for crate::Place<CheckoutAcssDebitMandateOptionsPaymentSchedule> {
299 fn string(&mut self, s: &str) -> miniserde::Result<()> {
300 use std::str::FromStr;
301 self.out =
302 Some(CheckoutAcssDebitMandateOptionsPaymentSchedule::from_str(s).expect("infallible"));
303 Ok(())
304 }
305}
306
307stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitMandateOptionsPaymentSchedule);
308#[cfg(feature = "deserialize")]
309impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitMandateOptionsPaymentSchedule {
310 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
311 use std::str::FromStr;
312 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
313 Ok(Self::from_str(&s).expect("infallible"))
314 }
315}
316#[derive(Clone, Eq, PartialEq)]
318#[non_exhaustive]
319pub enum CheckoutAcssDebitMandateOptionsTransactionType {
320 Business,
321 Personal,
322 Unknown(String),
324}
325impl CheckoutAcssDebitMandateOptionsTransactionType {
326 pub fn as_str(&self) -> &str {
327 use CheckoutAcssDebitMandateOptionsTransactionType::*;
328 match self {
329 Business => "business",
330 Personal => "personal",
331 Unknown(v) => v,
332 }
333 }
334}
335
336impl std::str::FromStr for CheckoutAcssDebitMandateOptionsTransactionType {
337 type Err = std::convert::Infallible;
338 fn from_str(s: &str) -> Result<Self, Self::Err> {
339 use CheckoutAcssDebitMandateOptionsTransactionType::*;
340 match s {
341 "business" => Ok(Business),
342 "personal" => Ok(Personal),
343 v => {
344 tracing::warn!(
345 "Unknown value '{}' for enum '{}'",
346 v,
347 "CheckoutAcssDebitMandateOptionsTransactionType"
348 );
349 Ok(Unknown(v.to_owned()))
350 }
351 }
352 }
353}
354impl std::fmt::Display for CheckoutAcssDebitMandateOptionsTransactionType {
355 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
356 f.write_str(self.as_str())
357 }
358}
359
360impl std::fmt::Debug for CheckoutAcssDebitMandateOptionsTransactionType {
361 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
362 f.write_str(self.as_str())
363 }
364}
365#[cfg(feature = "serialize")]
366impl serde::Serialize for CheckoutAcssDebitMandateOptionsTransactionType {
367 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
368 where
369 S: serde::Serializer,
370 {
371 serializer.serialize_str(self.as_str())
372 }
373}
374impl miniserde::Deserialize for CheckoutAcssDebitMandateOptionsTransactionType {
375 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
376 crate::Place::new(out)
377 }
378}
379
380impl miniserde::de::Visitor for crate::Place<CheckoutAcssDebitMandateOptionsTransactionType> {
381 fn string(&mut self, s: &str) -> miniserde::Result<()> {
382 use std::str::FromStr;
383 self.out =
384 Some(CheckoutAcssDebitMandateOptionsTransactionType::from_str(s).expect("infallible"));
385 Ok(())
386 }
387}
388
389stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitMandateOptionsTransactionType);
390#[cfg(feature = "deserialize")]
391impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitMandateOptionsTransactionType {
392 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
393 use std::str::FromStr;
394 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
395 Ok(Self::from_str(&s).expect("infallible"))
396 }
397}