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