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