stripe_shared/
issuing_authorization_three_d_secure.rs

1#[derive(Copy, Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct IssuingAuthorizationThreeDSecure {
5    /// The outcome of the 3D Secure authentication request.
6    pub result: IssuingAuthorizationThreeDSecureResult,
7}
8#[doc(hidden)]
9pub struct IssuingAuthorizationThreeDSecureBuilder {
10    result: Option<IssuingAuthorizationThreeDSecureResult>,
11}
12
13#[allow(
14    unused_variables,
15    irrefutable_let_patterns,
16    clippy::let_unit_value,
17    clippy::match_single_binding,
18    clippy::single_match
19)]
20const _: () = {
21    use miniserde::de::{Map, Visitor};
22    use miniserde::json::Value;
23    use miniserde::{make_place, Deserialize, Result};
24    use stripe_types::miniserde_helpers::FromValueOpt;
25    use stripe_types::{MapBuilder, ObjectDeser};
26
27    make_place!(Place);
28
29    impl Deserialize for IssuingAuthorizationThreeDSecure {
30        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
31            Place::new(out)
32        }
33    }
34
35    struct Builder<'a> {
36        out: &'a mut Option<IssuingAuthorizationThreeDSecure>,
37        builder: IssuingAuthorizationThreeDSecureBuilder,
38    }
39
40    impl Visitor for Place<IssuingAuthorizationThreeDSecure> {
41        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
42            Ok(Box::new(Builder {
43                out: &mut self.out,
44                builder: IssuingAuthorizationThreeDSecureBuilder::deser_default(),
45            }))
46        }
47    }
48
49    impl MapBuilder for IssuingAuthorizationThreeDSecureBuilder {
50        type Out = IssuingAuthorizationThreeDSecure;
51        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
52            Ok(match k {
53                "result" => Deserialize::begin(&mut self.result),
54
55                _ => <dyn Visitor>::ignore(),
56            })
57        }
58
59        fn deser_default() -> Self {
60            Self { result: Deserialize::default() }
61        }
62
63        fn take_out(&mut self) -> Option<Self::Out> {
64            let (Some(result),) = (self.result,) else {
65                return None;
66            };
67            Some(Self::Out { result })
68        }
69    }
70
71    impl<'a> Map for Builder<'a> {
72        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
73            self.builder.key(k)
74        }
75
76        fn finish(&mut self) -> Result<()> {
77            *self.out = self.builder.take_out();
78            Ok(())
79        }
80    }
81
82    impl ObjectDeser for IssuingAuthorizationThreeDSecure {
83        type Builder = IssuingAuthorizationThreeDSecureBuilder;
84    }
85
86    impl FromValueOpt for IssuingAuthorizationThreeDSecure {
87        fn from_value(v: Value) -> Option<Self> {
88            let Value::Object(obj) = v else {
89                return None;
90            };
91            let mut b = IssuingAuthorizationThreeDSecureBuilder::deser_default();
92            for (k, v) in obj {
93                match k.as_str() {
94                    "result" => b.result = FromValueOpt::from_value(v),
95
96                    _ => {}
97                }
98            }
99            b.take_out()
100        }
101    }
102};
103/// The outcome of the 3D Secure authentication request.
104#[derive(Copy, Clone, Eq, PartialEq)]
105pub enum IssuingAuthorizationThreeDSecureResult {
106    AttemptAcknowledged,
107    Authenticated,
108    Failed,
109    Required,
110}
111impl IssuingAuthorizationThreeDSecureResult {
112    pub fn as_str(self) -> &'static str {
113        use IssuingAuthorizationThreeDSecureResult::*;
114        match self {
115            AttemptAcknowledged => "attempt_acknowledged",
116            Authenticated => "authenticated",
117            Failed => "failed",
118            Required => "required",
119        }
120    }
121}
122
123impl std::str::FromStr for IssuingAuthorizationThreeDSecureResult {
124    type Err = stripe_types::StripeParseError;
125    fn from_str(s: &str) -> Result<Self, Self::Err> {
126        use IssuingAuthorizationThreeDSecureResult::*;
127        match s {
128            "attempt_acknowledged" => Ok(AttemptAcknowledged),
129            "authenticated" => Ok(Authenticated),
130            "failed" => Ok(Failed),
131            "required" => Ok(Required),
132            _ => Err(stripe_types::StripeParseError),
133        }
134    }
135}
136impl std::fmt::Display for IssuingAuthorizationThreeDSecureResult {
137    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
138        f.write_str(self.as_str())
139    }
140}
141
142impl std::fmt::Debug for IssuingAuthorizationThreeDSecureResult {
143    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
144        f.write_str(self.as_str())
145    }
146}
147#[cfg(feature = "serialize")]
148impl serde::Serialize for IssuingAuthorizationThreeDSecureResult {
149    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
150    where
151        S: serde::Serializer,
152    {
153        serializer.serialize_str(self.as_str())
154    }
155}
156impl miniserde::Deserialize for IssuingAuthorizationThreeDSecureResult {
157    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
158        crate::Place::new(out)
159    }
160}
161
162impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationThreeDSecureResult> {
163    fn string(&mut self, s: &str) -> miniserde::Result<()> {
164        use std::str::FromStr;
165        self.out = Some(
166            IssuingAuthorizationThreeDSecureResult::from_str(s).map_err(|_| miniserde::Error)?,
167        );
168        Ok(())
169    }
170}
171
172stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationThreeDSecureResult);
173#[cfg(feature = "deserialize")]
174impl<'de> serde::Deserialize<'de> for IssuingAuthorizationThreeDSecureResult {
175    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
176        use std::str::FromStr;
177        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
178        Self::from_str(&s).map_err(|_| {
179            serde::de::Error::custom("Unknown value for IssuingAuthorizationThreeDSecureResult")
180        })
181    }
182}