stripe_shared/
payment_pages_checkout_session_invoice_creation.rs1#[derive(Clone)]
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 PaymentPagesCheckoutSessionInvoiceCreation {
6 pub enabled: bool,
8 pub invoice_data: stripe_shared::PaymentPagesCheckoutSessionInvoiceSettings,
9}
10#[cfg(feature = "redact-generated-debug")]
11impl std::fmt::Debug for PaymentPagesCheckoutSessionInvoiceCreation {
12 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
13 f.debug_struct("PaymentPagesCheckoutSessionInvoiceCreation").finish_non_exhaustive()
14 }
15}
16#[doc(hidden)]
17pub struct PaymentPagesCheckoutSessionInvoiceCreationBuilder {
18 enabled: Option<bool>,
19 invoice_data: Option<stripe_shared::PaymentPagesCheckoutSessionInvoiceSettings>,
20}
21
22#[allow(
23 unused_variables,
24 irrefutable_let_patterns,
25 clippy::let_unit_value,
26 clippy::match_single_binding,
27 clippy::single_match
28)]
29const _: () = {
30 use miniserde::de::{Map, Visitor};
31 use miniserde::json::Value;
32 use miniserde::{Deserialize, Result, make_place};
33 use stripe_types::miniserde_helpers::FromValueOpt;
34 use stripe_types::{MapBuilder, ObjectDeser};
35
36 make_place!(Place);
37
38 impl Deserialize for PaymentPagesCheckoutSessionInvoiceCreation {
39 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
40 Place::new(out)
41 }
42 }
43
44 struct Builder<'a> {
45 out: &'a mut Option<PaymentPagesCheckoutSessionInvoiceCreation>,
46 builder: PaymentPagesCheckoutSessionInvoiceCreationBuilder,
47 }
48
49 impl Visitor for Place<PaymentPagesCheckoutSessionInvoiceCreation> {
50 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
51 Ok(Box::new(Builder {
52 out: &mut self.out,
53 builder: PaymentPagesCheckoutSessionInvoiceCreationBuilder::deser_default(),
54 }))
55 }
56 }
57
58 impl MapBuilder for PaymentPagesCheckoutSessionInvoiceCreationBuilder {
59 type Out = PaymentPagesCheckoutSessionInvoiceCreation;
60 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
61 Ok(match k {
62 "enabled" => Deserialize::begin(&mut self.enabled),
63 "invoice_data" => Deserialize::begin(&mut self.invoice_data),
64 _ => <dyn Visitor>::ignore(),
65 })
66 }
67
68 fn deser_default() -> Self {
69 Self { enabled: None, invoice_data: None }
70 }
71
72 fn take_out(&mut self) -> Option<Self::Out> {
73 let (Some(enabled), Some(invoice_data)) = (self.enabled, self.invoice_data.take())
74 else {
75 return None;
76 };
77 Some(Self::Out { enabled, invoice_data })
78 }
79 }
80
81 impl Map for Builder<'_> {
82 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
83 self.builder.key(k)
84 }
85
86 fn finish(&mut self) -> Result<()> {
87 *self.out = self.builder.take_out();
88 Ok(())
89 }
90 }
91
92 impl ObjectDeser for PaymentPagesCheckoutSessionInvoiceCreation {
93 type Builder = PaymentPagesCheckoutSessionInvoiceCreationBuilder;
94 }
95
96 impl FromValueOpt for PaymentPagesCheckoutSessionInvoiceCreation {
97 fn from_value(v: Value) -> Option<Self> {
98 let Value::Object(obj) = v else {
99 return None;
100 };
101 let mut b = PaymentPagesCheckoutSessionInvoiceCreationBuilder::deser_default();
102 for (k, v) in obj {
103 match k.as_str() {
104 "enabled" => b.enabled = FromValueOpt::from_value(v),
105 "invoice_data" => b.invoice_data = FromValueOpt::from_value(v),
106 _ => {}
107 }
108 }
109 b.take_out()
110 }
111 }
112};