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::{make_place, Deserialize, Result};
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
66                _ => <dyn Visitor>::ignore(),
67            })
68        }
69
70        fn deser_default() -> Self {
71            Self {
72                account_tax_ids: Deserialize::default(),
73                days_until_due: Deserialize::default(),
74                issuer: Deserialize::default(),
75            }
76        }
77
78        fn take_out(&mut self) -> Option<Self::Out> {
79            let (Some(account_tax_ids), Some(days_until_due), Some(issuer)) =
80                (self.account_tax_ids.take(), self.days_until_due, self.issuer.take())
81            else {
82                return None;
83            };
84            Some(Self::Out { account_tax_ids, days_until_due, issuer })
85        }
86    }
87
88    impl Map for Builder<'_> {
89        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
90            self.builder.key(k)
91        }
92
93        fn finish(&mut self) -> Result<()> {
94            *self.out = self.builder.take_out();
95            Ok(())
96        }
97    }
98
99    impl ObjectDeser for InvoiceSettingSubscriptionSchedulePhaseSetting {
100        type Builder = InvoiceSettingSubscriptionSchedulePhaseSettingBuilder;
101    }
102
103    impl FromValueOpt for InvoiceSettingSubscriptionSchedulePhaseSetting {
104        fn from_value(v: Value) -> Option<Self> {
105            let Value::Object(obj) = v else {
106                return None;
107            };
108            let mut b = InvoiceSettingSubscriptionSchedulePhaseSettingBuilder::deser_default();
109            for (k, v) in obj {
110                match k.as_str() {
111                    "account_tax_ids" => b.account_tax_ids = FromValueOpt::from_value(v),
112                    "days_until_due" => b.days_until_due = FromValueOpt::from_value(v),
113                    "issuer" => b.issuer = FromValueOpt::from_value(v),
114
115                    _ => {}
116                }
117            }
118            b.take_out()
119        }
120    }
121};