1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct AutomaticTax {
5 pub disabled_reason: Option<AutomaticTaxDisabledReason>,
7 pub enabled: bool,
10 pub liability: Option<stripe_shared::ConnectAccountReference>,
14 pub provider: Option<String>,
16 pub status: Option<AutomaticTaxStatus>,
18}
19#[doc(hidden)]
20pub struct AutomaticTaxBuilder {
21 disabled_reason: Option<Option<AutomaticTaxDisabledReason>>,
22 enabled: Option<bool>,
23 liability: Option<Option<stripe_shared::ConnectAccountReference>>,
24 provider: Option<Option<String>>,
25 status: Option<Option<AutomaticTaxStatus>>,
26}
27
28#[allow(
29 unused_variables,
30 irrefutable_let_patterns,
31 clippy::let_unit_value,
32 clippy::match_single_binding,
33 clippy::single_match
34)]
35const _: () = {
36 use miniserde::de::{Map, Visitor};
37 use miniserde::json::Value;
38 use miniserde::{Deserialize, Result, make_place};
39 use stripe_types::miniserde_helpers::FromValueOpt;
40 use stripe_types::{MapBuilder, ObjectDeser};
41
42 make_place!(Place);
43
44 impl Deserialize for AutomaticTax {
45 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
46 Place::new(out)
47 }
48 }
49
50 struct Builder<'a> {
51 out: &'a mut Option<AutomaticTax>,
52 builder: AutomaticTaxBuilder,
53 }
54
55 impl Visitor for Place<AutomaticTax> {
56 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
57 Ok(Box::new(Builder {
58 out: &mut self.out,
59 builder: AutomaticTaxBuilder::deser_default(),
60 }))
61 }
62 }
63
64 impl MapBuilder for AutomaticTaxBuilder {
65 type Out = AutomaticTax;
66 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
67 Ok(match k {
68 "disabled_reason" => Deserialize::begin(&mut self.disabled_reason),
69 "enabled" => Deserialize::begin(&mut self.enabled),
70 "liability" => Deserialize::begin(&mut self.liability),
71 "provider" => Deserialize::begin(&mut self.provider),
72 "status" => Deserialize::begin(&mut self.status),
73 _ => <dyn Visitor>::ignore(),
74 })
75 }
76
77 fn deser_default() -> Self {
78 Self {
79 disabled_reason: Deserialize::default(),
80 enabled: Deserialize::default(),
81 liability: Deserialize::default(),
82 provider: Deserialize::default(),
83 status: Deserialize::default(),
84 }
85 }
86
87 fn take_out(&mut self) -> Option<Self::Out> {
88 let (
89 Some(disabled_reason),
90 Some(enabled),
91 Some(liability),
92 Some(provider),
93 Some(status),
94 ) = (
95 self.disabled_reason.take(),
96 self.enabled,
97 self.liability.take(),
98 self.provider.take(),
99 self.status.take(),
100 )
101 else {
102 return None;
103 };
104 Some(Self::Out { disabled_reason, enabled, liability, provider, status })
105 }
106 }
107
108 impl Map for Builder<'_> {
109 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
110 self.builder.key(k)
111 }
112
113 fn finish(&mut self) -> Result<()> {
114 *self.out = self.builder.take_out();
115 Ok(())
116 }
117 }
118
119 impl ObjectDeser for AutomaticTax {
120 type Builder = AutomaticTaxBuilder;
121 }
122
123 impl FromValueOpt for AutomaticTax {
124 fn from_value(v: Value) -> Option<Self> {
125 let Value::Object(obj) = v else {
126 return None;
127 };
128 let mut b = AutomaticTaxBuilder::deser_default();
129 for (k, v) in obj {
130 match k.as_str() {
131 "disabled_reason" => b.disabled_reason = FromValueOpt::from_value(v),
132 "enabled" => b.enabled = FromValueOpt::from_value(v),
133 "liability" => b.liability = FromValueOpt::from_value(v),
134 "provider" => b.provider = FromValueOpt::from_value(v),
135 "status" => b.status = FromValueOpt::from_value(v),
136 _ => {}
137 }
138 }
139 b.take_out()
140 }
141 }
142};
143#[derive(Clone, Eq, PartialEq)]
145#[non_exhaustive]
146pub enum AutomaticTaxDisabledReason {
147 FinalizationRequiresLocationInputs,
148 FinalizationSystemError,
149 Unknown(String),
151}
152impl AutomaticTaxDisabledReason {
153 pub fn as_str(&self) -> &str {
154 use AutomaticTaxDisabledReason::*;
155 match self {
156 FinalizationRequiresLocationInputs => "finalization_requires_location_inputs",
157 FinalizationSystemError => "finalization_system_error",
158 Unknown(v) => v,
159 }
160 }
161}
162
163impl std::str::FromStr for AutomaticTaxDisabledReason {
164 type Err = std::convert::Infallible;
165 fn from_str(s: &str) -> Result<Self, Self::Err> {
166 use AutomaticTaxDisabledReason::*;
167 match s {
168 "finalization_requires_location_inputs" => Ok(FinalizationRequiresLocationInputs),
169 "finalization_system_error" => Ok(FinalizationSystemError),
170 v => {
171 tracing::warn!("Unknown value '{}' for enum '{}'", v, "AutomaticTaxDisabledReason");
172 Ok(Unknown(v.to_owned()))
173 }
174 }
175 }
176}
177impl std::fmt::Display for AutomaticTaxDisabledReason {
178 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
179 f.write_str(self.as_str())
180 }
181}
182
183impl std::fmt::Debug for AutomaticTaxDisabledReason {
184 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
185 f.write_str(self.as_str())
186 }
187}
188#[cfg(feature = "serialize")]
189impl serde::Serialize for AutomaticTaxDisabledReason {
190 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
191 where
192 S: serde::Serializer,
193 {
194 serializer.serialize_str(self.as_str())
195 }
196}
197impl miniserde::Deserialize for AutomaticTaxDisabledReason {
198 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
199 crate::Place::new(out)
200 }
201}
202
203impl miniserde::de::Visitor for crate::Place<AutomaticTaxDisabledReason> {
204 fn string(&mut self, s: &str) -> miniserde::Result<()> {
205 use std::str::FromStr;
206 self.out = Some(AutomaticTaxDisabledReason::from_str(s).expect("infallible"));
207 Ok(())
208 }
209}
210
211stripe_types::impl_from_val_with_from_str!(AutomaticTaxDisabledReason);
212#[cfg(feature = "deserialize")]
213impl<'de> serde::Deserialize<'de> for AutomaticTaxDisabledReason {
214 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
215 use std::str::FromStr;
216 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
217 Ok(Self::from_str(&s).expect("infallible"))
218 }
219}
220#[derive(Clone, Eq, PartialEq)]
222#[non_exhaustive]
223pub enum AutomaticTaxStatus {
224 Complete,
225 Failed,
226 RequiresLocationInputs,
227 Unknown(String),
229}
230impl AutomaticTaxStatus {
231 pub fn as_str(&self) -> &str {
232 use AutomaticTaxStatus::*;
233 match self {
234 Complete => "complete",
235 Failed => "failed",
236 RequiresLocationInputs => "requires_location_inputs",
237 Unknown(v) => v,
238 }
239 }
240}
241
242impl std::str::FromStr for AutomaticTaxStatus {
243 type Err = std::convert::Infallible;
244 fn from_str(s: &str) -> Result<Self, Self::Err> {
245 use AutomaticTaxStatus::*;
246 match s {
247 "complete" => Ok(Complete),
248 "failed" => Ok(Failed),
249 "requires_location_inputs" => Ok(RequiresLocationInputs),
250 v => {
251 tracing::warn!("Unknown value '{}' for enum '{}'", v, "AutomaticTaxStatus");
252 Ok(Unknown(v.to_owned()))
253 }
254 }
255 }
256}
257impl std::fmt::Display for AutomaticTaxStatus {
258 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
259 f.write_str(self.as_str())
260 }
261}
262
263impl std::fmt::Debug for AutomaticTaxStatus {
264 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
265 f.write_str(self.as_str())
266 }
267}
268#[cfg(feature = "serialize")]
269impl serde::Serialize for AutomaticTaxStatus {
270 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
271 where
272 S: serde::Serializer,
273 {
274 serializer.serialize_str(self.as_str())
275 }
276}
277impl miniserde::Deserialize for AutomaticTaxStatus {
278 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
279 crate::Place::new(out)
280 }
281}
282
283impl miniserde::de::Visitor for crate::Place<AutomaticTaxStatus> {
284 fn string(&mut self, s: &str) -> miniserde::Result<()> {
285 use std::str::FromStr;
286 self.out = Some(AutomaticTaxStatus::from_str(s).expect("infallible"));
287 Ok(())
288 }
289}
290
291stripe_types::impl_from_val_with_from_str!(AutomaticTaxStatus);
292#[cfg(feature = "deserialize")]
293impl<'de> serde::Deserialize<'de> for AutomaticTaxStatus {
294 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
295 use std::str::FromStr;
296 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
297 Ok(Self::from_str(&s).expect("infallible"))
298 }
299}