stripe_shared/
issuing_authorization_authentication_exemption.rs1#[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 IssuingAuthorizationAuthenticationExemption {
6 pub claimed_by: IssuingAuthorizationAuthenticationExemptionClaimedBy,
8 #[cfg_attr(any(feature = "deserialize", feature = "serialize"), serde(rename = "type"))]
10 pub type_: IssuingAuthorizationAuthenticationExemptionType,
11}
12#[cfg(feature = "redact-generated-debug")]
13impl std::fmt::Debug for IssuingAuthorizationAuthenticationExemption {
14 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
15 f.debug_struct("IssuingAuthorizationAuthenticationExemption").finish_non_exhaustive()
16 }
17}
18#[doc(hidden)]
19pub struct IssuingAuthorizationAuthenticationExemptionBuilder {
20 claimed_by: Option<IssuingAuthorizationAuthenticationExemptionClaimedBy>,
21 type_: Option<IssuingAuthorizationAuthenticationExemptionType>,
22}
23
24#[allow(
25 unused_variables,
26 irrefutable_let_patterns,
27 clippy::let_unit_value,
28 clippy::match_single_binding,
29 clippy::single_match
30)]
31const _: () = {
32 use miniserde::de::{Map, Visitor};
33 use miniserde::json::Value;
34 use miniserde::{Deserialize, Result, make_place};
35 use stripe_types::miniserde_helpers::FromValueOpt;
36 use stripe_types::{MapBuilder, ObjectDeser};
37
38 make_place!(Place);
39
40 impl Deserialize for IssuingAuthorizationAuthenticationExemption {
41 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
42 Place::new(out)
43 }
44 }
45
46 struct Builder<'a> {
47 out: &'a mut Option<IssuingAuthorizationAuthenticationExemption>,
48 builder: IssuingAuthorizationAuthenticationExemptionBuilder,
49 }
50
51 impl Visitor for Place<IssuingAuthorizationAuthenticationExemption> {
52 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
53 Ok(Box::new(Builder {
54 out: &mut self.out,
55 builder: IssuingAuthorizationAuthenticationExemptionBuilder::deser_default(),
56 }))
57 }
58 }
59
60 impl MapBuilder for IssuingAuthorizationAuthenticationExemptionBuilder {
61 type Out = IssuingAuthorizationAuthenticationExemption;
62 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
63 Ok(match k {
64 "claimed_by" => Deserialize::begin(&mut self.claimed_by),
65 "type" => Deserialize::begin(&mut self.type_),
66 _ => <dyn Visitor>::ignore(),
67 })
68 }
69
70 fn deser_default() -> Self {
71 Self { claimed_by: None, type_: None }
72 }
73
74 fn take_out(&mut self) -> Option<Self::Out> {
75 let (Some(claimed_by), Some(type_)) = (self.claimed_by.take(), self.type_.take())
76 else {
77 return None;
78 };
79 Some(Self::Out { claimed_by, type_ })
80 }
81 }
82
83 impl Map for Builder<'_> {
84 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
85 self.builder.key(k)
86 }
87
88 fn finish(&mut self) -> Result<()> {
89 *self.out = self.builder.take_out();
90 Ok(())
91 }
92 }
93
94 impl ObjectDeser for IssuingAuthorizationAuthenticationExemption {
95 type Builder = IssuingAuthorizationAuthenticationExemptionBuilder;
96 }
97
98 impl FromValueOpt for IssuingAuthorizationAuthenticationExemption {
99 fn from_value(v: Value) -> Option<Self> {
100 let Value::Object(obj) = v else {
101 return None;
102 };
103 let mut b = IssuingAuthorizationAuthenticationExemptionBuilder::deser_default();
104 for (k, v) in obj {
105 match k.as_str() {
106 "claimed_by" => b.claimed_by = FromValueOpt::from_value(v),
107 "type" => b.type_ = FromValueOpt::from_value(v),
108 _ => {}
109 }
110 }
111 b.take_out()
112 }
113 }
114};
115#[derive(Clone, Eq, PartialEq)]
117#[non_exhaustive]
118pub enum IssuingAuthorizationAuthenticationExemptionClaimedBy {
119 Acquirer,
120 Issuer,
121 Unknown(String),
123}
124impl IssuingAuthorizationAuthenticationExemptionClaimedBy {
125 pub fn as_str(&self) -> &str {
126 use IssuingAuthorizationAuthenticationExemptionClaimedBy::*;
127 match self {
128 Acquirer => "acquirer",
129 Issuer => "issuer",
130 Unknown(v) => v,
131 }
132 }
133}
134
135impl std::str::FromStr for IssuingAuthorizationAuthenticationExemptionClaimedBy {
136 type Err = std::convert::Infallible;
137 fn from_str(s: &str) -> Result<Self, Self::Err> {
138 use IssuingAuthorizationAuthenticationExemptionClaimedBy::*;
139 match s {
140 "acquirer" => Ok(Acquirer),
141 "issuer" => Ok(Issuer),
142 v => {
143 tracing::warn!(
144 "Unknown value '{}' for enum '{}'",
145 v,
146 "IssuingAuthorizationAuthenticationExemptionClaimedBy"
147 );
148 Ok(Unknown(v.to_owned()))
149 }
150 }
151 }
152}
153impl std::fmt::Display for IssuingAuthorizationAuthenticationExemptionClaimedBy {
154 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
155 f.write_str(self.as_str())
156 }
157}
158
159#[cfg(not(feature = "redact-generated-debug"))]
160impl std::fmt::Debug for IssuingAuthorizationAuthenticationExemptionClaimedBy {
161 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
162 f.write_str(self.as_str())
163 }
164}
165#[cfg(feature = "redact-generated-debug")]
166impl std::fmt::Debug for IssuingAuthorizationAuthenticationExemptionClaimedBy {
167 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
168 f.debug_struct(stringify!(IssuingAuthorizationAuthenticationExemptionClaimedBy))
169 .finish_non_exhaustive()
170 }
171}
172#[cfg(feature = "serialize")]
173impl serde::Serialize for IssuingAuthorizationAuthenticationExemptionClaimedBy {
174 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
175 where
176 S: serde::Serializer,
177 {
178 serializer.serialize_str(self.as_str())
179 }
180}
181impl miniserde::Deserialize for IssuingAuthorizationAuthenticationExemptionClaimedBy {
182 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
183 crate::Place::new(out)
184 }
185}
186
187impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationAuthenticationExemptionClaimedBy> {
188 fn string(&mut self, s: &str) -> miniserde::Result<()> {
189 use std::str::FromStr;
190 self.out = Some(
191 IssuingAuthorizationAuthenticationExemptionClaimedBy::from_str(s).expect("infallible"),
192 );
193 Ok(())
194 }
195}
196
197stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationAuthenticationExemptionClaimedBy);
198#[cfg(feature = "deserialize")]
199impl<'de> serde::Deserialize<'de> for IssuingAuthorizationAuthenticationExemptionClaimedBy {
200 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
201 use std::str::FromStr;
202 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
203 Ok(Self::from_str(&s).expect("infallible"))
204 }
205}
206#[derive(Clone, Eq, PartialEq)]
208#[non_exhaustive]
209pub enum IssuingAuthorizationAuthenticationExemptionType {
210 LowValueTransaction,
211 TransactionRiskAnalysis,
212 Unknown,
213 _Unknown(String),
216}
217impl IssuingAuthorizationAuthenticationExemptionType {
218 pub fn as_str(&self) -> &str {
219 use IssuingAuthorizationAuthenticationExemptionType::*;
220 match self {
221 LowValueTransaction => "low_value_transaction",
222 TransactionRiskAnalysis => "transaction_risk_analysis",
223 Unknown => "unknown",
224 _Unknown(v) => v,
225 }
226 }
227}
228
229impl std::str::FromStr for IssuingAuthorizationAuthenticationExemptionType {
230 type Err = std::convert::Infallible;
231 fn from_str(s: &str) -> Result<Self, Self::Err> {
232 use IssuingAuthorizationAuthenticationExemptionType::*;
233 match s {
234 "low_value_transaction" => Ok(LowValueTransaction),
235 "transaction_risk_analysis" => Ok(TransactionRiskAnalysis),
236 "unknown" => Ok(Unknown),
237 v => {
238 tracing::warn!(
239 "Unknown value '{}' for enum '{}'",
240 v,
241 "IssuingAuthorizationAuthenticationExemptionType"
242 );
243 Ok(_Unknown(v.to_owned()))
244 }
245 }
246 }
247}
248impl std::fmt::Display for IssuingAuthorizationAuthenticationExemptionType {
249 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
250 f.write_str(self.as_str())
251 }
252}
253
254#[cfg(not(feature = "redact-generated-debug"))]
255impl std::fmt::Debug for IssuingAuthorizationAuthenticationExemptionType {
256 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
257 f.write_str(self.as_str())
258 }
259}
260#[cfg(feature = "redact-generated-debug")]
261impl std::fmt::Debug for IssuingAuthorizationAuthenticationExemptionType {
262 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
263 f.debug_struct(stringify!(IssuingAuthorizationAuthenticationExemptionType))
264 .finish_non_exhaustive()
265 }
266}
267#[cfg(feature = "serialize")]
268impl serde::Serialize for IssuingAuthorizationAuthenticationExemptionType {
269 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
270 where
271 S: serde::Serializer,
272 {
273 serializer.serialize_str(self.as_str())
274 }
275}
276impl miniserde::Deserialize for IssuingAuthorizationAuthenticationExemptionType {
277 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
278 crate::Place::new(out)
279 }
280}
281
282impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationAuthenticationExemptionType> {
283 fn string(&mut self, s: &str) -> miniserde::Result<()> {
284 use std::str::FromStr;
285 self.out =
286 Some(IssuingAuthorizationAuthenticationExemptionType::from_str(s).expect("infallible"));
287 Ok(())
288 }
289}
290
291stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationAuthenticationExemptionType);
292#[cfg(feature = "deserialize")]
293impl<'de> serde::Deserialize<'de> for IssuingAuthorizationAuthenticationExemptionType {
294 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
295 use std::str::FromStr;
296 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
297 Ok(Self::from_str(&s).expect("infallible"))
298 }
299}