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