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    /// Number of days within which a customer must pay invoices generated by this subscription schedule.
10    /// This value will be `null` for subscription schedules where `billing=charge_automatically`.
11    pub days_until_due: Option<u32>,
12    /// The connected account that issues the invoice.
13    /// The invoice is presented with the branding and support information of the specified account.
14    pub issuer: Option<stripe_shared::ConnectAccountReference>,
15}
16#[cfg(feature = "redact-generated-debug")]
17impl std::fmt::Debug for InvoiceSettingSubscriptionSchedulePhaseSetting {
18    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
19        f.debug_struct("InvoiceSettingSubscriptionSchedulePhaseSetting").finish_non_exhaustive()
20    }
21}
22#[doc(hidden)]
23pub struct InvoiceSettingSubscriptionSchedulePhaseSettingBuilder {
24    account_tax_ids: Option<Option<Vec<stripe_types::Expandable<stripe_shared::TaxId>>>>,
25    days_until_due: Option<Option<u32>>,
26    issuer: Option<Option<stripe_shared::ConnectAccountReference>>,
27}
28
29#[allow(
30    unused_variables,
31    irrefutable_let_patterns,
32    clippy::let_unit_value,
33    clippy::match_single_binding,
34    clippy::single_match
35)]
36const _: () = {
37    use miniserde::de::{Map, Visitor};
38    use miniserde::json::Value;
39    use miniserde::{Deserialize, Result, make_place};
40    use stripe_types::miniserde_helpers::FromValueOpt;
41    use stripe_types::{MapBuilder, ObjectDeser};
42
43    make_place!(Place);
44
45    impl Deserialize for InvoiceSettingSubscriptionSchedulePhaseSetting {
46        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
47            Place::new(out)
48        }
49    }
50
51    struct Builder<'a> {
52        out: &'a mut Option<InvoiceSettingSubscriptionSchedulePhaseSetting>,
53        builder: InvoiceSettingSubscriptionSchedulePhaseSettingBuilder,
54    }
55
56    impl Visitor for Place<InvoiceSettingSubscriptionSchedulePhaseSetting> {
57        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
58            Ok(Box::new(Builder {
59                out: &mut self.out,
60                builder: InvoiceSettingSubscriptionSchedulePhaseSettingBuilder::deser_default(),
61            }))
62        }
63    }
64
65    impl MapBuilder for InvoiceSettingSubscriptionSchedulePhaseSettingBuilder {
66        type Out = InvoiceSettingSubscriptionSchedulePhaseSetting;
67        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
68            Ok(match k {
69                "account_tax_ids" => Deserialize::begin(&mut self.account_tax_ids),
70                "days_until_due" => Deserialize::begin(&mut self.days_until_due),
71                "issuer" => Deserialize::begin(&mut self.issuer),
72                _ => <dyn Visitor>::ignore(),
73            })
74        }
75
76        fn deser_default() -> Self {
77            Self { account_tax_ids: Some(None), days_until_due: Some(None), issuer: Some(None) }
78        }
79
80        fn take_out(&mut self) -> Option<Self::Out> {
81            let (Some(account_tax_ids), Some(days_until_due), Some(issuer)) =
82                (self.account_tax_ids.take(), self.days_until_due, self.issuer.take())
83            else {
84                return None;
85            };
86            Some(Self::Out { account_tax_ids, days_until_due, issuer })
87        }
88    }
89
90    impl Map for Builder<'_> {
91        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
92            self.builder.key(k)
93        }
94
95        fn finish(&mut self) -> Result<()> {
96            *self.out = self.builder.take_out();
97            Ok(())
98        }
99    }
100
101    impl ObjectDeser for InvoiceSettingSubscriptionSchedulePhaseSetting {
102        type Builder = InvoiceSettingSubscriptionSchedulePhaseSettingBuilder;
103    }
104
105    impl FromValueOpt for InvoiceSettingSubscriptionSchedulePhaseSetting {
106        fn from_value(v: Value) -> Option<Self> {
107            let Value::Object(obj) = v else {
108                return None;
109            };
110            let mut b = InvoiceSettingSubscriptionSchedulePhaseSettingBuilder::deser_default();
111            for (k, v) in obj {
112                match k.as_str() {
113                    "account_tax_ids" => b.account_tax_ids = FromValueOpt::from_value(v),
114                    "days_until_due" => b.days_until_due = FromValueOpt::from_value(v),
115                    "issuer" => b.issuer = FromValueOpt::from_value(v),
116                    _ => {}
117                }
118            }
119            b.take_out()
120        }
121    }
122};