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