1#[derive(Clone, Eq, PartialEq)]
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 IssuingAuthorizationFuelData {
6 pub industry_product_code: Option<String>,
8 pub quantity_decimal: Option<String>,
10 #[cfg_attr(any(feature = "deserialize", feature = "serialize"), serde(rename = "type"))]
12 pub type_: Option<IssuingAuthorizationFuelDataType>,
13 pub unit: Option<IssuingAuthorizationFuelDataUnit>,
15 pub unit_cost_decimal: Option<String>,
17}
18#[cfg(feature = "redact-generated-debug")]
19impl std::fmt::Debug for IssuingAuthorizationFuelData {
20 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
21 f.debug_struct("IssuingAuthorizationFuelData").finish_non_exhaustive()
22 }
23}
24#[doc(hidden)]
25pub struct IssuingAuthorizationFuelDataBuilder {
26 industry_product_code: Option<Option<String>>,
27 quantity_decimal: Option<Option<String>>,
28 type_: Option<Option<IssuingAuthorizationFuelDataType>>,
29 unit: Option<Option<IssuingAuthorizationFuelDataUnit>>,
30 unit_cost_decimal: Option<Option<String>>,
31}
32
33#[allow(
34 unused_variables,
35 irrefutable_let_patterns,
36 clippy::let_unit_value,
37 clippy::match_single_binding,
38 clippy::single_match
39)]
40const _: () = {
41 use miniserde::de::{Map, Visitor};
42 use miniserde::json::Value;
43 use miniserde::{Deserialize, Result, make_place};
44 use stripe_types::miniserde_helpers::FromValueOpt;
45 use stripe_types::{MapBuilder, ObjectDeser};
46
47 make_place!(Place);
48
49 impl Deserialize for IssuingAuthorizationFuelData {
50 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
51 Place::new(out)
52 }
53 }
54
55 struct Builder<'a> {
56 out: &'a mut Option<IssuingAuthorizationFuelData>,
57 builder: IssuingAuthorizationFuelDataBuilder,
58 }
59
60 impl Visitor for Place<IssuingAuthorizationFuelData> {
61 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
62 Ok(Box::new(Builder {
63 out: &mut self.out,
64 builder: IssuingAuthorizationFuelDataBuilder::deser_default(),
65 }))
66 }
67 }
68
69 impl MapBuilder for IssuingAuthorizationFuelDataBuilder {
70 type Out = IssuingAuthorizationFuelData;
71 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
72 Ok(match k {
73 "industry_product_code" => Deserialize::begin(&mut self.industry_product_code),
74 "quantity_decimal" => Deserialize::begin(&mut self.quantity_decimal),
75 "type" => Deserialize::begin(&mut self.type_),
76 "unit" => Deserialize::begin(&mut self.unit),
77 "unit_cost_decimal" => Deserialize::begin(&mut self.unit_cost_decimal),
78 _ => <dyn Visitor>::ignore(),
79 })
80 }
81
82 fn deser_default() -> Self {
83 Self {
84 industry_product_code: Some(None),
85 quantity_decimal: Some(None),
86 type_: Some(None),
87 unit: Some(None),
88 unit_cost_decimal: Some(None),
89 }
90 }
91
92 fn take_out(&mut self) -> Option<Self::Out> {
93 let (
94 Some(industry_product_code),
95 Some(quantity_decimal),
96 Some(type_),
97 Some(unit),
98 Some(unit_cost_decimal),
99 ) = (
100 self.industry_product_code.take(),
101 self.quantity_decimal.take(),
102 self.type_.take(),
103 self.unit.take(),
104 self.unit_cost_decimal.take(),
105 )
106 else {
107 return None;
108 };
109 Some(Self::Out {
110 industry_product_code,
111 quantity_decimal,
112 type_,
113 unit,
114 unit_cost_decimal,
115 })
116 }
117 }
118
119 impl Map for Builder<'_> {
120 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
121 self.builder.key(k)
122 }
123
124 fn finish(&mut self) -> Result<()> {
125 *self.out = self.builder.take_out();
126 Ok(())
127 }
128 }
129
130 impl ObjectDeser for IssuingAuthorizationFuelData {
131 type Builder = IssuingAuthorizationFuelDataBuilder;
132 }
133
134 impl FromValueOpt for IssuingAuthorizationFuelData {
135 fn from_value(v: Value) -> Option<Self> {
136 let Value::Object(obj) = v else {
137 return None;
138 };
139 let mut b = IssuingAuthorizationFuelDataBuilder::deser_default();
140 for (k, v) in obj {
141 match k.as_str() {
142 "industry_product_code" => {
143 b.industry_product_code = FromValueOpt::from_value(v)
144 }
145 "quantity_decimal" => b.quantity_decimal = FromValueOpt::from_value(v),
146 "type" => b.type_ = FromValueOpt::from_value(v),
147 "unit" => b.unit = FromValueOpt::from_value(v),
148 "unit_cost_decimal" => b.unit_cost_decimal = FromValueOpt::from_value(v),
149 _ => {}
150 }
151 }
152 b.take_out()
153 }
154 }
155};
156#[derive(Clone, Eq, PartialEq)]
158#[non_exhaustive]
159pub enum IssuingAuthorizationFuelDataType {
160 Diesel,
161 Other,
162 UnleadedPlus,
163 UnleadedRegular,
164 UnleadedSuper,
165 Unknown(String),
167}
168impl IssuingAuthorizationFuelDataType {
169 pub fn as_str(&self) -> &str {
170 use IssuingAuthorizationFuelDataType::*;
171 match self {
172 Diesel => "diesel",
173 Other => "other",
174 UnleadedPlus => "unleaded_plus",
175 UnleadedRegular => "unleaded_regular",
176 UnleadedSuper => "unleaded_super",
177 Unknown(v) => v,
178 }
179 }
180}
181
182impl std::str::FromStr for IssuingAuthorizationFuelDataType {
183 type Err = std::convert::Infallible;
184 fn from_str(s: &str) -> Result<Self, Self::Err> {
185 use IssuingAuthorizationFuelDataType::*;
186 match s {
187 "diesel" => Ok(Diesel),
188 "other" => Ok(Other),
189 "unleaded_plus" => Ok(UnleadedPlus),
190 "unleaded_regular" => Ok(UnleadedRegular),
191 "unleaded_super" => Ok(UnleadedSuper),
192 v => {
193 tracing::warn!(
194 "Unknown value '{}' for enum '{}'",
195 v,
196 "IssuingAuthorizationFuelDataType"
197 );
198 Ok(Unknown(v.to_owned()))
199 }
200 }
201 }
202}
203impl std::fmt::Display for IssuingAuthorizationFuelDataType {
204 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
205 f.write_str(self.as_str())
206 }
207}
208
209#[cfg(not(feature = "redact-generated-debug"))]
210impl std::fmt::Debug for IssuingAuthorizationFuelDataType {
211 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
212 f.write_str(self.as_str())
213 }
214}
215#[cfg(feature = "redact-generated-debug")]
216impl std::fmt::Debug for IssuingAuthorizationFuelDataType {
217 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
218 f.debug_struct(stringify!(IssuingAuthorizationFuelDataType)).finish_non_exhaustive()
219 }
220}
221#[cfg(feature = "serialize")]
222impl serde::Serialize for IssuingAuthorizationFuelDataType {
223 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
224 where
225 S: serde::Serializer,
226 {
227 serializer.serialize_str(self.as_str())
228 }
229}
230impl miniserde::Deserialize for IssuingAuthorizationFuelDataType {
231 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
232 crate::Place::new(out)
233 }
234}
235
236impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationFuelDataType> {
237 fn string(&mut self, s: &str) -> miniserde::Result<()> {
238 use std::str::FromStr;
239 self.out = Some(IssuingAuthorizationFuelDataType::from_str(s).expect("infallible"));
240 Ok(())
241 }
242}
243
244stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationFuelDataType);
245#[cfg(feature = "deserialize")]
246impl<'de> serde::Deserialize<'de> for IssuingAuthorizationFuelDataType {
247 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
248 use std::str::FromStr;
249 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
250 Ok(Self::from_str(&s).expect("infallible"))
251 }
252}
253#[derive(Clone, Eq, PartialEq)]
255#[non_exhaustive]
256pub enum IssuingAuthorizationFuelDataUnit {
257 ChargingMinute,
258 ImperialGallon,
259 Kilogram,
260 KilowattHour,
261 Liter,
262 Other,
263 Pound,
264 UsGallon,
265 Unknown(String),
267}
268impl IssuingAuthorizationFuelDataUnit {
269 pub fn as_str(&self) -> &str {
270 use IssuingAuthorizationFuelDataUnit::*;
271 match self {
272 ChargingMinute => "charging_minute",
273 ImperialGallon => "imperial_gallon",
274 Kilogram => "kilogram",
275 KilowattHour => "kilowatt_hour",
276 Liter => "liter",
277 Other => "other",
278 Pound => "pound",
279 UsGallon => "us_gallon",
280 Unknown(v) => v,
281 }
282 }
283}
284
285impl std::str::FromStr for IssuingAuthorizationFuelDataUnit {
286 type Err = std::convert::Infallible;
287 fn from_str(s: &str) -> Result<Self, Self::Err> {
288 use IssuingAuthorizationFuelDataUnit::*;
289 match s {
290 "charging_minute" => Ok(ChargingMinute),
291 "imperial_gallon" => Ok(ImperialGallon),
292 "kilogram" => Ok(Kilogram),
293 "kilowatt_hour" => Ok(KilowattHour),
294 "liter" => Ok(Liter),
295 "other" => Ok(Other),
296 "pound" => Ok(Pound),
297 "us_gallon" => Ok(UsGallon),
298 v => {
299 tracing::warn!(
300 "Unknown value '{}' for enum '{}'",
301 v,
302 "IssuingAuthorizationFuelDataUnit"
303 );
304 Ok(Unknown(v.to_owned()))
305 }
306 }
307 }
308}
309impl std::fmt::Display for IssuingAuthorizationFuelDataUnit {
310 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
311 f.write_str(self.as_str())
312 }
313}
314
315#[cfg(not(feature = "redact-generated-debug"))]
316impl std::fmt::Debug for IssuingAuthorizationFuelDataUnit {
317 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
318 f.write_str(self.as_str())
319 }
320}
321#[cfg(feature = "redact-generated-debug")]
322impl std::fmt::Debug for IssuingAuthorizationFuelDataUnit {
323 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
324 f.debug_struct(stringify!(IssuingAuthorizationFuelDataUnit)).finish_non_exhaustive()
325 }
326}
327#[cfg(feature = "serialize")]
328impl serde::Serialize for IssuingAuthorizationFuelDataUnit {
329 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
330 where
331 S: serde::Serializer,
332 {
333 serializer.serialize_str(self.as_str())
334 }
335}
336impl miniserde::Deserialize for IssuingAuthorizationFuelDataUnit {
337 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
338 crate::Place::new(out)
339 }
340}
341
342impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationFuelDataUnit> {
343 fn string(&mut self, s: &str) -> miniserde::Result<()> {
344 use std::str::FromStr;
345 self.out = Some(IssuingAuthorizationFuelDataUnit::from_str(s).expect("infallible"));
346 Ok(())
347 }
348}
349
350stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationFuelDataUnit);
351#[cfg(feature = "deserialize")]
352impl<'de> serde::Deserialize<'de> for IssuingAuthorizationFuelDataUnit {
353 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
354 use std::str::FromStr;
355 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
356 Ok(Self::from_str(&s).expect("infallible"))
357 }
358}