Skip to main content

stripe_shared/
invoice_setting_subscription_schedule_setting.rs

1#[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 InvoiceSettingSubscriptionScheduleSetting {
6    /// The account tax IDs associated with the subscription schedule.
7    /// Will be set on invoices generated by the subscription schedule.
8    pub account_tax_ids: Option<Vec<stripe_types::Expandable<stripe_shared::TaxId>>>,
9    /// A list of up to 4 custom fields to be displayed on the invoice.
10    pub custom_fields: Option<Vec<stripe_shared::InvoiceSettingCustomField>>,
11    /// Number of days within which a customer must pay invoices generated by this subscription schedule.
12    /// This value will be `null` for subscription schedules where `billing=charge_automatically`.
13    pub days_until_due: Option<u32>,
14    /// An arbitrary string attached to the object. Often useful for displaying to users.
15    pub description: Option<String>,
16    /// Footer to be displayed on the invoice.
17    pub footer: Option<String>,
18    pub issuer: stripe_shared::ConnectAccountReference,
19}
20#[cfg(feature = "redact-generated-debug")]
21impl std::fmt::Debug for InvoiceSettingSubscriptionScheduleSetting {
22    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
23        f.debug_struct("InvoiceSettingSubscriptionScheduleSetting").finish_non_exhaustive()
24    }
25}
26#[doc(hidden)]
27pub struct InvoiceSettingSubscriptionScheduleSettingBuilder {
28    account_tax_ids: Option<Option<Vec<stripe_types::Expandable<stripe_shared::TaxId>>>>,
29    custom_fields: Option<Option<Vec<stripe_shared::InvoiceSettingCustomField>>>,
30    days_until_due: Option<Option<u32>>,
31    description: Option<Option<String>>,
32    footer: Option<Option<String>>,
33    issuer: Option<stripe_shared::ConnectAccountReference>,
34}
35
36#[allow(
37    unused_variables,
38    irrefutable_let_patterns,
39    clippy::let_unit_value,
40    clippy::match_single_binding,
41    clippy::single_match
42)]
43const _: () = {
44    use miniserde::de::{Map, Visitor};
45    use miniserde::json::Value;
46    use miniserde::{Deserialize, Result, make_place};
47    use stripe_types::miniserde_helpers::FromValueOpt;
48    use stripe_types::{MapBuilder, ObjectDeser};
49
50    make_place!(Place);
51
52    impl Deserialize for InvoiceSettingSubscriptionScheduleSetting {
53        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
54            Place::new(out)
55        }
56    }
57
58    struct Builder<'a> {
59        out: &'a mut Option<InvoiceSettingSubscriptionScheduleSetting>,
60        builder: InvoiceSettingSubscriptionScheduleSettingBuilder,
61    }
62
63    impl Visitor for Place<InvoiceSettingSubscriptionScheduleSetting> {
64        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
65            Ok(Box::new(Builder {
66                out: &mut self.out,
67                builder: InvoiceSettingSubscriptionScheduleSettingBuilder::deser_default(),
68            }))
69        }
70    }
71
72    impl MapBuilder for InvoiceSettingSubscriptionScheduleSettingBuilder {
73        type Out = InvoiceSettingSubscriptionScheduleSetting;
74        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
75            Ok(match k {
76                "account_tax_ids" => Deserialize::begin(&mut self.account_tax_ids),
77                "custom_fields" => Deserialize::begin(&mut self.custom_fields),
78                "days_until_due" => Deserialize::begin(&mut self.days_until_due),
79                "description" => Deserialize::begin(&mut self.description),
80                "footer" => Deserialize::begin(&mut self.footer),
81                "issuer" => Deserialize::begin(&mut self.issuer),
82                _ => <dyn Visitor>::ignore(),
83            })
84        }
85
86        fn deser_default() -> Self {
87            Self {
88                account_tax_ids: Some(None),
89                custom_fields: Some(None),
90                days_until_due: Some(None),
91                description: Some(None),
92                footer: Some(None),
93                issuer: None,
94            }
95        }
96
97        fn take_out(&mut self) -> Option<Self::Out> {
98            let (
99                Some(account_tax_ids),
100                Some(custom_fields),
101                Some(days_until_due),
102                Some(description),
103                Some(footer),
104                Some(issuer),
105            ) = (
106                self.account_tax_ids.take(),
107                self.custom_fields.take(),
108                self.days_until_due,
109                self.description.take(),
110                self.footer.take(),
111                self.issuer.take(),
112            )
113            else {
114                return None;
115            };
116            Some(Self::Out {
117                account_tax_ids,
118                custom_fields,
119                days_until_due,
120                description,
121                footer,
122                issuer,
123            })
124        }
125    }
126
127    impl Map for Builder<'_> {
128        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
129            self.builder.key(k)
130        }
131
132        fn finish(&mut self) -> Result<()> {
133            *self.out = self.builder.take_out();
134            Ok(())
135        }
136    }
137
138    impl ObjectDeser for InvoiceSettingSubscriptionScheduleSetting {
139        type Builder = InvoiceSettingSubscriptionScheduleSettingBuilder;
140    }
141
142    impl FromValueOpt for InvoiceSettingSubscriptionScheduleSetting {
143        fn from_value(v: Value) -> Option<Self> {
144            let Value::Object(obj) = v else {
145                return None;
146            };
147            let mut b = InvoiceSettingSubscriptionScheduleSettingBuilder::deser_default();
148            for (k, v) in obj {
149                match k.as_str() {
150                    "account_tax_ids" => b.account_tax_ids = FromValueOpt::from_value(v),
151                    "custom_fields" => b.custom_fields = FromValueOpt::from_value(v),
152                    "days_until_due" => b.days_until_due = FromValueOpt::from_value(v),
153                    "description" => b.description = FromValueOpt::from_value(v),
154                    "footer" => b.footer = FromValueOpt::from_value(v),
155                    "issuer" => b.issuer = FromValueOpt::from_value(v),
156                    _ => {}
157                }
158            }
159            b.take_out()
160        }
161    }
162};