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