Skip to main content

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