1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct SubscriptionSchedulesResourceDefaultSettings {
5 pub application_fee_percent: Option<f64>,
8 pub automatic_tax:
9 Option<stripe_shared::SubscriptionSchedulesResourceDefaultSettingsAutomaticTax>,
10 pub billing_cycle_anchor: SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor,
15 pub billing_thresholds: Option<stripe_shared::SubscriptionBillingThresholds>,
17 pub collection_method: Option<SubscriptionSchedulesResourceDefaultSettingsCollectionMethod>,
21 pub default_payment_method: Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>,
24 pub description: Option<String>,
27 pub invoice_settings: stripe_shared::InvoiceSettingSubscriptionScheduleSetting,
28 pub on_behalf_of: Option<stripe_types::Expandable<stripe_shared::Account>>,
31 pub transfer_data: Option<stripe_shared::SubscriptionTransferData>,
33}
34#[doc(hidden)]
35pub struct SubscriptionSchedulesResourceDefaultSettingsBuilder {
36 application_fee_percent: Option<Option<f64>>,
37 automatic_tax:
38 Option<Option<stripe_shared::SubscriptionSchedulesResourceDefaultSettingsAutomaticTax>>,
39 billing_cycle_anchor: Option<SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor>,
40 billing_thresholds: Option<Option<stripe_shared::SubscriptionBillingThresholds>>,
41 collection_method: Option<Option<SubscriptionSchedulesResourceDefaultSettingsCollectionMethod>>,
42 default_payment_method: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>,
43 description: Option<Option<String>>,
44 invoice_settings: Option<stripe_shared::InvoiceSettingSubscriptionScheduleSetting>,
45 on_behalf_of: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>,
46 transfer_data: Option<Option<stripe_shared::SubscriptionTransferData>>,
47}
48
49#[allow(
50 unused_variables,
51 irrefutable_let_patterns,
52 clippy::let_unit_value,
53 clippy::match_single_binding,
54 clippy::single_match
55)]
56const _: () = {
57 use miniserde::de::{Map, Visitor};
58 use miniserde::json::Value;
59 use miniserde::{Deserialize, Result, make_place};
60 use stripe_types::miniserde_helpers::FromValueOpt;
61 use stripe_types::{MapBuilder, ObjectDeser};
62
63 make_place!(Place);
64
65 impl Deserialize for SubscriptionSchedulesResourceDefaultSettings {
66 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
67 Place::new(out)
68 }
69 }
70
71 struct Builder<'a> {
72 out: &'a mut Option<SubscriptionSchedulesResourceDefaultSettings>,
73 builder: SubscriptionSchedulesResourceDefaultSettingsBuilder,
74 }
75
76 impl Visitor for Place<SubscriptionSchedulesResourceDefaultSettings> {
77 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
78 Ok(Box::new(Builder {
79 out: &mut self.out,
80 builder: SubscriptionSchedulesResourceDefaultSettingsBuilder::deser_default(),
81 }))
82 }
83 }
84
85 impl MapBuilder for SubscriptionSchedulesResourceDefaultSettingsBuilder {
86 type Out = SubscriptionSchedulesResourceDefaultSettings;
87 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
88 Ok(match k {
89 "application_fee_percent" => Deserialize::begin(&mut self.application_fee_percent),
90 "automatic_tax" => Deserialize::begin(&mut self.automatic_tax),
91 "billing_cycle_anchor" => Deserialize::begin(&mut self.billing_cycle_anchor),
92 "billing_thresholds" => Deserialize::begin(&mut self.billing_thresholds),
93 "collection_method" => Deserialize::begin(&mut self.collection_method),
94 "default_payment_method" => Deserialize::begin(&mut self.default_payment_method),
95 "description" => Deserialize::begin(&mut self.description),
96 "invoice_settings" => Deserialize::begin(&mut self.invoice_settings),
97 "on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of),
98 "transfer_data" => Deserialize::begin(&mut self.transfer_data),
99 _ => <dyn Visitor>::ignore(),
100 })
101 }
102
103 fn deser_default() -> Self {
104 Self {
105 application_fee_percent: Deserialize::default(),
106 automatic_tax: Deserialize::default(),
107 billing_cycle_anchor: Deserialize::default(),
108 billing_thresholds: Deserialize::default(),
109 collection_method: Deserialize::default(),
110 default_payment_method: Deserialize::default(),
111 description: Deserialize::default(),
112 invoice_settings: Deserialize::default(),
113 on_behalf_of: Deserialize::default(),
114 transfer_data: Deserialize::default(),
115 }
116 }
117
118 fn take_out(&mut self) -> Option<Self::Out> {
119 let (
120 Some(application_fee_percent),
121 Some(automatic_tax),
122 Some(billing_cycle_anchor),
123 Some(billing_thresholds),
124 Some(collection_method),
125 Some(default_payment_method),
126 Some(description),
127 Some(invoice_settings),
128 Some(on_behalf_of),
129 Some(transfer_data),
130 ) = (
131 self.application_fee_percent,
132 self.automatic_tax.take(),
133 self.billing_cycle_anchor.take(),
134 self.billing_thresholds,
135 self.collection_method.take(),
136 self.default_payment_method.take(),
137 self.description.take(),
138 self.invoice_settings.take(),
139 self.on_behalf_of.take(),
140 self.transfer_data.take(),
141 )
142 else {
143 return None;
144 };
145 Some(Self::Out {
146 application_fee_percent,
147 automatic_tax,
148 billing_cycle_anchor,
149 billing_thresholds,
150 collection_method,
151 default_payment_method,
152 description,
153 invoice_settings,
154 on_behalf_of,
155 transfer_data,
156 })
157 }
158 }
159
160 impl Map for Builder<'_> {
161 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
162 self.builder.key(k)
163 }
164
165 fn finish(&mut self) -> Result<()> {
166 *self.out = self.builder.take_out();
167 Ok(())
168 }
169 }
170
171 impl ObjectDeser for SubscriptionSchedulesResourceDefaultSettings {
172 type Builder = SubscriptionSchedulesResourceDefaultSettingsBuilder;
173 }
174
175 impl FromValueOpt for SubscriptionSchedulesResourceDefaultSettings {
176 fn from_value(v: Value) -> Option<Self> {
177 let Value::Object(obj) = v else {
178 return None;
179 };
180 let mut b = SubscriptionSchedulesResourceDefaultSettingsBuilder::deser_default();
181 for (k, v) in obj {
182 match k.as_str() {
183 "application_fee_percent" => {
184 b.application_fee_percent = FromValueOpt::from_value(v)
185 }
186 "automatic_tax" => b.automatic_tax = FromValueOpt::from_value(v),
187 "billing_cycle_anchor" => b.billing_cycle_anchor = FromValueOpt::from_value(v),
188 "billing_thresholds" => b.billing_thresholds = FromValueOpt::from_value(v),
189 "collection_method" => b.collection_method = FromValueOpt::from_value(v),
190 "default_payment_method" => {
191 b.default_payment_method = FromValueOpt::from_value(v)
192 }
193 "description" => b.description = FromValueOpt::from_value(v),
194 "invoice_settings" => b.invoice_settings = FromValueOpt::from_value(v),
195 "on_behalf_of" => b.on_behalf_of = FromValueOpt::from_value(v),
196 "transfer_data" => b.transfer_data = FromValueOpt::from_value(v),
197 _ => {}
198 }
199 }
200 b.take_out()
201 }
202 }
203};
204#[derive(Clone, Eq, PartialEq)]
209#[non_exhaustive]
210pub enum SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor {
211 Automatic,
212 PhaseStart,
213 Unknown(String),
215}
216impl SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor {
217 pub fn as_str(&self) -> &str {
218 use SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor::*;
219 match self {
220 Automatic => "automatic",
221 PhaseStart => "phase_start",
222 Unknown(v) => v,
223 }
224 }
225}
226
227impl std::str::FromStr for SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor {
228 type Err = std::convert::Infallible;
229 fn from_str(s: &str) -> Result<Self, Self::Err> {
230 use SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor::*;
231 match s {
232 "automatic" => Ok(Automatic),
233 "phase_start" => Ok(PhaseStart),
234 v => {
235 tracing::warn!(
236 "Unknown value '{}' for enum '{}'",
237 v,
238 "SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor"
239 );
240 Ok(Unknown(v.to_owned()))
241 }
242 }
243 }
244}
245impl std::fmt::Display for SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor {
246 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
247 f.write_str(self.as_str())
248 }
249}
250
251impl std::fmt::Debug for SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor {
252 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
253 f.write_str(self.as_str())
254 }
255}
256#[cfg(feature = "serialize")]
257impl serde::Serialize for SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor {
258 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
259 where
260 S: serde::Serializer,
261 {
262 serializer.serialize_str(self.as_str())
263 }
264}
265impl miniserde::Deserialize for SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor {
266 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
267 crate::Place::new(out)
268 }
269}
270
271impl miniserde::de::Visitor
272 for crate::Place<SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor>
273{
274 fn string(&mut self, s: &str) -> miniserde::Result<()> {
275 use std::str::FromStr;
276 self.out = Some(
277 SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor::from_str(s)
278 .expect("infallible"),
279 );
280 Ok(())
281 }
282}
283
284stripe_types::impl_from_val_with_from_str!(
285 SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor
286);
287#[cfg(feature = "deserialize")]
288impl<'de> serde::Deserialize<'de>
289 for SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor
290{
291 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
292 use std::str::FromStr;
293 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
294 Ok(Self::from_str(&s).expect("infallible"))
295 }
296}
297#[derive(Clone, Eq, PartialEq)]
301#[non_exhaustive]
302pub enum SubscriptionSchedulesResourceDefaultSettingsCollectionMethod {
303 ChargeAutomatically,
304 SendInvoice,
305 Unknown(String),
307}
308impl SubscriptionSchedulesResourceDefaultSettingsCollectionMethod {
309 pub fn as_str(&self) -> &str {
310 use SubscriptionSchedulesResourceDefaultSettingsCollectionMethod::*;
311 match self {
312 ChargeAutomatically => "charge_automatically",
313 SendInvoice => "send_invoice",
314 Unknown(v) => v,
315 }
316 }
317}
318
319impl std::str::FromStr for SubscriptionSchedulesResourceDefaultSettingsCollectionMethod {
320 type Err = std::convert::Infallible;
321 fn from_str(s: &str) -> Result<Self, Self::Err> {
322 use SubscriptionSchedulesResourceDefaultSettingsCollectionMethod::*;
323 match s {
324 "charge_automatically" => Ok(ChargeAutomatically),
325 "send_invoice" => Ok(SendInvoice),
326 v => {
327 tracing::warn!(
328 "Unknown value '{}' for enum '{}'",
329 v,
330 "SubscriptionSchedulesResourceDefaultSettingsCollectionMethod"
331 );
332 Ok(Unknown(v.to_owned()))
333 }
334 }
335 }
336}
337impl std::fmt::Display for SubscriptionSchedulesResourceDefaultSettingsCollectionMethod {
338 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
339 f.write_str(self.as_str())
340 }
341}
342
343impl std::fmt::Debug for SubscriptionSchedulesResourceDefaultSettingsCollectionMethod {
344 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
345 f.write_str(self.as_str())
346 }
347}
348#[cfg(feature = "serialize")]
349impl serde::Serialize for SubscriptionSchedulesResourceDefaultSettingsCollectionMethod {
350 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
351 where
352 S: serde::Serializer,
353 {
354 serializer.serialize_str(self.as_str())
355 }
356}
357impl miniserde::Deserialize for SubscriptionSchedulesResourceDefaultSettingsCollectionMethod {
358 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
359 crate::Place::new(out)
360 }
361}
362
363impl miniserde::de::Visitor
364 for crate::Place<SubscriptionSchedulesResourceDefaultSettingsCollectionMethod>
365{
366 fn string(&mut self, s: &str) -> miniserde::Result<()> {
367 use std::str::FromStr;
368 self.out = Some(
369 SubscriptionSchedulesResourceDefaultSettingsCollectionMethod::from_str(s)
370 .expect("infallible"),
371 );
372 Ok(())
373 }
374}
375
376stripe_types::impl_from_val_with_from_str!(
377 SubscriptionSchedulesResourceDefaultSettingsCollectionMethod
378);
379#[cfg(feature = "deserialize")]
380impl<'de> serde::Deserialize<'de> for SubscriptionSchedulesResourceDefaultSettingsCollectionMethod {
381 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
382 use std::str::FromStr;
383 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
384 Ok(Self::from_str(&s).expect("infallible"))
385 }
386}