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