stripe_shared/
invoice_setting_subscription_schedule_phase_setting.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct InvoiceSettingSubscriptionSchedulePhaseSetting {
5    /// The account tax IDs associated with this phase of the subscription schedule.
6    /// Will be set on invoices generated by this phase of the subscription schedule.
7    pub account_tax_ids: Option<Vec<stripe_types::Expandable<stripe_shared::TaxId>>>,
8    /// Number of days within which a customer must pay invoices generated by this subscription schedule.
9    /// This value will be `null` for subscription schedules where `billing=charge_automatically`.
10    pub days_until_due: Option<u32>,
11    /// The connected account that issues the invoice.
12    /// The invoice is presented with the branding and support information of the specified account.
13    pub issuer: Option<stripe_shared::ConnectAccountReference>,
14}
15#[doc(hidden)]
16pub struct InvoiceSettingSubscriptionSchedulePhaseSettingBuilder {
17    account_tax_ids: Option<Option<Vec<stripe_types::Expandable<stripe_shared::TaxId>>>>,
18    days_until_due: Option<Option<u32>>,
19    issuer: Option<Option<stripe_shared::ConnectAccountReference>>,
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 InvoiceSettingSubscriptionSchedulePhaseSetting {
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<InvoiceSettingSubscriptionSchedulePhaseSetting>,
46        builder: InvoiceSettingSubscriptionSchedulePhaseSettingBuilder,
47    }
48
49    impl Visitor for Place<InvoiceSettingSubscriptionSchedulePhaseSetting> {
50        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
51            Ok(Box::new(Builder {
52                out: &mut self.out,
53                builder: InvoiceSettingSubscriptionSchedulePhaseSettingBuilder::deser_default(),
54            }))
55        }
56    }
57
58    impl MapBuilder for InvoiceSettingSubscriptionSchedulePhaseSettingBuilder {
59        type Out = InvoiceSettingSubscriptionSchedulePhaseSetting;
60        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
61            Ok(match k {
62                "account_tax_ids" => Deserialize::begin(&mut self.account_tax_ids),
63                "days_until_due" => Deserialize::begin(&mut self.days_until_due),
64                "issuer" => Deserialize::begin(&mut self.issuer),
65                _ => <dyn Visitor>::ignore(),
66            })
67        }
68
69        fn deser_default() -> Self {
70            Self {
71                account_tax_ids: Deserialize::default(),
72                days_until_due: Deserialize::default(),
73                issuer: Deserialize::default(),
74            }
75        }
76
77        fn take_out(&mut self) -> Option<Self::Out> {
78            let (Some(account_tax_ids), Some(days_until_due), Some(issuer)) =
79                (self.account_tax_ids.take(), self.days_until_due, self.issuer.take())
80            else {
81                return None;
82            };
83            Some(Self::Out { account_tax_ids, days_until_due, issuer })
84        }
85    }
86
87    impl Map for Builder<'_> {
88        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
89            self.builder.key(k)
90        }
91
92        fn finish(&mut self) -> Result<()> {
93            *self.out = self.builder.take_out();
94            Ok(())
95        }
96    }
97
98    impl ObjectDeser for InvoiceSettingSubscriptionSchedulePhaseSetting {
99        type Builder = InvoiceSettingSubscriptionSchedulePhaseSettingBuilder;
100    }
101
102    impl FromValueOpt for InvoiceSettingSubscriptionSchedulePhaseSetting {
103        fn from_value(v: Value) -> Option<Self> {
104            let Value::Object(obj) = v else {
105                return None;
106            };
107            let mut b = InvoiceSettingSubscriptionSchedulePhaseSettingBuilder::deser_default();
108            for (k, v) in obj {
109                match k.as_str() {
110                    "account_tax_ids" => b.account_tax_ids = FromValueOpt::from_value(v),
111                    "days_until_due" => b.days_until_due = FromValueOpt::from_value(v),
112                    "issuer" => b.issuer = FromValueOpt::from_value(v),
113                    _ => {}
114                }
115            }
116            b.take_out()
117        }
118    }
119};