1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct IssuingAuthorizationFleetData {
5 pub cardholder_prompt_data:
9 Option<stripe_shared::IssuingAuthorizationFleetCardholderPromptData>,
10 pub purchase_type: Option<IssuingAuthorizationFleetDataPurchaseType>,
12 pub reported_breakdown: Option<stripe_shared::IssuingAuthorizationFleetReportedBreakdown>,
16 pub service_type: Option<IssuingAuthorizationFleetDataServiceType>,
18}
19#[doc(hidden)]
20pub struct IssuingAuthorizationFleetDataBuilder {
21 cardholder_prompt_data:
22 Option<Option<stripe_shared::IssuingAuthorizationFleetCardholderPromptData>>,
23 purchase_type: Option<Option<IssuingAuthorizationFleetDataPurchaseType>>,
24 reported_breakdown: Option<Option<stripe_shared::IssuingAuthorizationFleetReportedBreakdown>>,
25 service_type: Option<Option<IssuingAuthorizationFleetDataServiceType>>,
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 IssuingAuthorizationFleetData {
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<IssuingAuthorizationFleetData>,
52 builder: IssuingAuthorizationFleetDataBuilder,
53 }
54
55 impl Visitor for Place<IssuingAuthorizationFleetData> {
56 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
57 Ok(Box::new(Builder {
58 out: &mut self.out,
59 builder: IssuingAuthorizationFleetDataBuilder::deser_default(),
60 }))
61 }
62 }
63
64 impl MapBuilder for IssuingAuthorizationFleetDataBuilder {
65 type Out = IssuingAuthorizationFleetData;
66 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
67 Ok(match k {
68 "cardholder_prompt_data" => Deserialize::begin(&mut self.cardholder_prompt_data),
69 "purchase_type" => Deserialize::begin(&mut self.purchase_type),
70 "reported_breakdown" => Deserialize::begin(&mut self.reported_breakdown),
71 "service_type" => Deserialize::begin(&mut self.service_type),
72 _ => <dyn Visitor>::ignore(),
73 })
74 }
75
76 fn deser_default() -> Self {
77 Self {
78 cardholder_prompt_data: Deserialize::default(),
79 purchase_type: Deserialize::default(),
80 reported_breakdown: Deserialize::default(),
81 service_type: Deserialize::default(),
82 }
83 }
84
85 fn take_out(&mut self) -> Option<Self::Out> {
86 let (
87 Some(cardholder_prompt_data),
88 Some(purchase_type),
89 Some(reported_breakdown),
90 Some(service_type),
91 ) = (
92 self.cardholder_prompt_data.take(),
93 self.purchase_type.take(),
94 self.reported_breakdown.take(),
95 self.service_type.take(),
96 )
97 else {
98 return None;
99 };
100 Some(Self::Out {
101 cardholder_prompt_data,
102 purchase_type,
103 reported_breakdown,
104 service_type,
105 })
106 }
107 }
108
109 impl Map for Builder<'_> {
110 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
111 self.builder.key(k)
112 }
113
114 fn finish(&mut self) -> Result<()> {
115 *self.out = self.builder.take_out();
116 Ok(())
117 }
118 }
119
120 impl ObjectDeser for IssuingAuthorizationFleetData {
121 type Builder = IssuingAuthorizationFleetDataBuilder;
122 }
123
124 impl FromValueOpt for IssuingAuthorizationFleetData {
125 fn from_value(v: Value) -> Option<Self> {
126 let Value::Object(obj) = v else {
127 return None;
128 };
129 let mut b = IssuingAuthorizationFleetDataBuilder::deser_default();
130 for (k, v) in obj {
131 match k.as_str() {
132 "cardholder_prompt_data" => {
133 b.cardholder_prompt_data = FromValueOpt::from_value(v)
134 }
135 "purchase_type" => b.purchase_type = FromValueOpt::from_value(v),
136 "reported_breakdown" => b.reported_breakdown = FromValueOpt::from_value(v),
137 "service_type" => b.service_type = FromValueOpt::from_value(v),
138 _ => {}
139 }
140 }
141 b.take_out()
142 }
143 }
144};
145#[derive(Clone, Eq, PartialEq)]
147#[non_exhaustive]
148pub enum IssuingAuthorizationFleetDataPurchaseType {
149 FuelAndNonFuelPurchase,
150 FuelPurchase,
151 NonFuelPurchase,
152 Unknown(String),
154}
155impl IssuingAuthorizationFleetDataPurchaseType {
156 pub fn as_str(&self) -> &str {
157 use IssuingAuthorizationFleetDataPurchaseType::*;
158 match self {
159 FuelAndNonFuelPurchase => "fuel_and_non_fuel_purchase",
160 FuelPurchase => "fuel_purchase",
161 NonFuelPurchase => "non_fuel_purchase",
162 Unknown(v) => v,
163 }
164 }
165}
166
167impl std::str::FromStr for IssuingAuthorizationFleetDataPurchaseType {
168 type Err = std::convert::Infallible;
169 fn from_str(s: &str) -> Result<Self, Self::Err> {
170 use IssuingAuthorizationFleetDataPurchaseType::*;
171 match s {
172 "fuel_and_non_fuel_purchase" => Ok(FuelAndNonFuelPurchase),
173 "fuel_purchase" => Ok(FuelPurchase),
174 "non_fuel_purchase" => Ok(NonFuelPurchase),
175 v => {
176 tracing::warn!(
177 "Unknown value '{}' for enum '{}'",
178 v,
179 "IssuingAuthorizationFleetDataPurchaseType"
180 );
181 Ok(Unknown(v.to_owned()))
182 }
183 }
184 }
185}
186impl std::fmt::Display for IssuingAuthorizationFleetDataPurchaseType {
187 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
188 f.write_str(self.as_str())
189 }
190}
191
192impl std::fmt::Debug for IssuingAuthorizationFleetDataPurchaseType {
193 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
194 f.write_str(self.as_str())
195 }
196}
197#[cfg(feature = "serialize")]
198impl serde::Serialize for IssuingAuthorizationFleetDataPurchaseType {
199 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
200 where
201 S: serde::Serializer,
202 {
203 serializer.serialize_str(self.as_str())
204 }
205}
206impl miniserde::Deserialize for IssuingAuthorizationFleetDataPurchaseType {
207 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
208 crate::Place::new(out)
209 }
210}
211
212impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationFleetDataPurchaseType> {
213 fn string(&mut self, s: &str) -> miniserde::Result<()> {
214 use std::str::FromStr;
215 self.out =
216 Some(IssuingAuthorizationFleetDataPurchaseType::from_str(s).expect("infallible"));
217 Ok(())
218 }
219}
220
221stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationFleetDataPurchaseType);
222#[cfg(feature = "deserialize")]
223impl<'de> serde::Deserialize<'de> for IssuingAuthorizationFleetDataPurchaseType {
224 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
225 use std::str::FromStr;
226 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
227 Ok(Self::from_str(&s).expect("infallible"))
228 }
229}
230#[derive(Clone, Eq, PartialEq)]
232#[non_exhaustive]
233pub enum IssuingAuthorizationFleetDataServiceType {
234 FullService,
235 NonFuelTransaction,
236 SelfService,
237 Unknown(String),
239}
240impl IssuingAuthorizationFleetDataServiceType {
241 pub fn as_str(&self) -> &str {
242 use IssuingAuthorizationFleetDataServiceType::*;
243 match self {
244 FullService => "full_service",
245 NonFuelTransaction => "non_fuel_transaction",
246 SelfService => "self_service",
247 Unknown(v) => v,
248 }
249 }
250}
251
252impl std::str::FromStr for IssuingAuthorizationFleetDataServiceType {
253 type Err = std::convert::Infallible;
254 fn from_str(s: &str) -> Result<Self, Self::Err> {
255 use IssuingAuthorizationFleetDataServiceType::*;
256 match s {
257 "full_service" => Ok(FullService),
258 "non_fuel_transaction" => Ok(NonFuelTransaction),
259 "self_service" => Ok(SelfService),
260 v => {
261 tracing::warn!(
262 "Unknown value '{}' for enum '{}'",
263 v,
264 "IssuingAuthorizationFleetDataServiceType"
265 );
266 Ok(Unknown(v.to_owned()))
267 }
268 }
269 }
270}
271impl std::fmt::Display for IssuingAuthorizationFleetDataServiceType {
272 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
273 f.write_str(self.as_str())
274 }
275}
276
277impl std::fmt::Debug for IssuingAuthorizationFleetDataServiceType {
278 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
279 f.write_str(self.as_str())
280 }
281}
282#[cfg(feature = "serialize")]
283impl serde::Serialize for IssuingAuthorizationFleetDataServiceType {
284 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
285 where
286 S: serde::Serializer,
287 {
288 serializer.serialize_str(self.as_str())
289 }
290}
291impl miniserde::Deserialize for IssuingAuthorizationFleetDataServiceType {
292 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
293 crate::Place::new(out)
294 }
295}
296
297impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationFleetDataServiceType> {
298 fn string(&mut self, s: &str) -> miniserde::Result<()> {
299 use std::str::FromStr;
300 self.out = Some(IssuingAuthorizationFleetDataServiceType::from_str(s).expect("infallible"));
301 Ok(())
302 }
303}
304
305stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationFleetDataServiceType);
306#[cfg(feature = "deserialize")]
307impl<'de> serde::Deserialize<'de> for IssuingAuthorizationFleetDataServiceType {
308 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
309 use std::str::FromStr;
310 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
311 Ok(Self::from_str(&s).expect("infallible"))
312 }
313}