1#[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 IssuingAuthorizationRequest {
6 pub amount: i64,
9 pub amount_details: Option<stripe_shared::IssuingAuthorizationAmountDetails>,
12 pub approved: bool,
14 pub authorization_code: Option<String>,
20 pub created: stripe_types::Timestamp,
22 pub currency: stripe_types::Currency,
25 pub merchant_amount: i64,
27 pub merchant_currency: stripe_types::Currency,
31 pub network_risk_score: Option<i64>,
34 pub reason: IssuingAuthorizationRequestReason,
36 pub reason_message: Option<String>,
38 pub requested_at: Option<stripe_types::Timestamp>,
41}
42#[cfg(feature = "redact-generated-debug")]
43impl std::fmt::Debug for IssuingAuthorizationRequest {
44 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
45 f.debug_struct("IssuingAuthorizationRequest").finish_non_exhaustive()
46 }
47}
48#[doc(hidden)]
49pub struct IssuingAuthorizationRequestBuilder {
50 amount: Option<i64>,
51 amount_details: Option<Option<stripe_shared::IssuingAuthorizationAmountDetails>>,
52 approved: Option<bool>,
53 authorization_code: Option<Option<String>>,
54 created: Option<stripe_types::Timestamp>,
55 currency: Option<stripe_types::Currency>,
56 merchant_amount: Option<i64>,
57 merchant_currency: Option<stripe_types::Currency>,
58 network_risk_score: Option<Option<i64>>,
59 reason: Option<IssuingAuthorizationRequestReason>,
60 reason_message: Option<Option<String>>,
61 requested_at: Option<Option<stripe_types::Timestamp>>,
62}
63
64#[allow(
65 unused_variables,
66 irrefutable_let_patterns,
67 clippy::let_unit_value,
68 clippy::match_single_binding,
69 clippy::single_match
70)]
71const _: () = {
72 use miniserde::de::{Map, Visitor};
73 use miniserde::json::Value;
74 use miniserde::{Deserialize, Result, make_place};
75 use stripe_types::miniserde_helpers::FromValueOpt;
76 use stripe_types::{MapBuilder, ObjectDeser};
77
78 make_place!(Place);
79
80 impl Deserialize for IssuingAuthorizationRequest {
81 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
82 Place::new(out)
83 }
84 }
85
86 struct Builder<'a> {
87 out: &'a mut Option<IssuingAuthorizationRequest>,
88 builder: IssuingAuthorizationRequestBuilder,
89 }
90
91 impl Visitor for Place<IssuingAuthorizationRequest> {
92 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
93 Ok(Box::new(Builder {
94 out: &mut self.out,
95 builder: IssuingAuthorizationRequestBuilder::deser_default(),
96 }))
97 }
98 }
99
100 impl MapBuilder for IssuingAuthorizationRequestBuilder {
101 type Out = IssuingAuthorizationRequest;
102 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
103 Ok(match k {
104 "amount" => Deserialize::begin(&mut self.amount),
105 "amount_details" => Deserialize::begin(&mut self.amount_details),
106 "approved" => Deserialize::begin(&mut self.approved),
107 "authorization_code" => Deserialize::begin(&mut self.authorization_code),
108 "created" => Deserialize::begin(&mut self.created),
109 "currency" => Deserialize::begin(&mut self.currency),
110 "merchant_amount" => Deserialize::begin(&mut self.merchant_amount),
111 "merchant_currency" => Deserialize::begin(&mut self.merchant_currency),
112 "network_risk_score" => Deserialize::begin(&mut self.network_risk_score),
113 "reason" => Deserialize::begin(&mut self.reason),
114 "reason_message" => Deserialize::begin(&mut self.reason_message),
115 "requested_at" => Deserialize::begin(&mut self.requested_at),
116 _ => <dyn Visitor>::ignore(),
117 })
118 }
119
120 fn deser_default() -> Self {
121 Self {
122 amount: None,
123 amount_details: Some(None),
124 approved: None,
125 authorization_code: Some(None),
126 created: None,
127 currency: None,
128 merchant_amount: None,
129 merchant_currency: None,
130 network_risk_score: Some(None),
131 reason: None,
132 reason_message: Some(None),
133 requested_at: Some(None),
134 }
135 }
136
137 fn take_out(&mut self) -> Option<Self::Out> {
138 let (
139 Some(amount),
140 Some(amount_details),
141 Some(approved),
142 Some(authorization_code),
143 Some(created),
144 Some(currency),
145 Some(merchant_amount),
146 Some(merchant_currency),
147 Some(network_risk_score),
148 Some(reason),
149 Some(reason_message),
150 Some(requested_at),
151 ) = (
152 self.amount,
153 self.amount_details,
154 self.approved,
155 self.authorization_code.take(),
156 self.created,
157 self.currency.take(),
158 self.merchant_amount,
159 self.merchant_currency.take(),
160 self.network_risk_score,
161 self.reason.take(),
162 self.reason_message.take(),
163 self.requested_at,
164 )
165 else {
166 return None;
167 };
168 Some(Self::Out {
169 amount,
170 amount_details,
171 approved,
172 authorization_code,
173 created,
174 currency,
175 merchant_amount,
176 merchant_currency,
177 network_risk_score,
178 reason,
179 reason_message,
180 requested_at,
181 })
182 }
183 }
184
185 impl Map for Builder<'_> {
186 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
187 self.builder.key(k)
188 }
189
190 fn finish(&mut self) -> Result<()> {
191 *self.out = self.builder.take_out();
192 Ok(())
193 }
194 }
195
196 impl ObjectDeser for IssuingAuthorizationRequest {
197 type Builder = IssuingAuthorizationRequestBuilder;
198 }
199
200 impl FromValueOpt for IssuingAuthorizationRequest {
201 fn from_value(v: Value) -> Option<Self> {
202 let Value::Object(obj) = v else {
203 return None;
204 };
205 let mut b = IssuingAuthorizationRequestBuilder::deser_default();
206 for (k, v) in obj {
207 match k.as_str() {
208 "amount" => b.amount = FromValueOpt::from_value(v),
209 "amount_details" => b.amount_details = FromValueOpt::from_value(v),
210 "approved" => b.approved = FromValueOpt::from_value(v),
211 "authorization_code" => b.authorization_code = FromValueOpt::from_value(v),
212 "created" => b.created = FromValueOpt::from_value(v),
213 "currency" => b.currency = FromValueOpt::from_value(v),
214 "merchant_amount" => b.merchant_amount = FromValueOpt::from_value(v),
215 "merchant_currency" => b.merchant_currency = FromValueOpt::from_value(v),
216 "network_risk_score" => b.network_risk_score = FromValueOpt::from_value(v),
217 "reason" => b.reason = FromValueOpt::from_value(v),
218 "reason_message" => b.reason_message = FromValueOpt::from_value(v),
219 "requested_at" => b.requested_at = FromValueOpt::from_value(v),
220 _ => {}
221 }
222 }
223 b.take_out()
224 }
225 }
226};
227#[derive(Clone, Eq, PartialEq)]
229#[non_exhaustive]
230pub enum IssuingAuthorizationRequestReason {
231 AccountDisabled,
232 CardActive,
233 CardCanceled,
234 CardExpired,
235 CardInactive,
236 CardholderBlocked,
237 CardholderInactive,
238 CardholderVerificationRequired,
239 InsecureAuthorizationMethod,
240 InsufficientFunds,
241 NetworkFallback,
242 NotAllowed,
243 PinBlocked,
244 SpendingControls,
245 StripeInternalError,
246 SuspectedFraud,
247 VerificationFailed,
248 WebhookApproved,
249 WebhookDeclined,
250 WebhookError,
251 WebhookTimeout,
252 Unknown(String),
254}
255impl IssuingAuthorizationRequestReason {
256 pub fn as_str(&self) -> &str {
257 use IssuingAuthorizationRequestReason::*;
258 match self {
259 AccountDisabled => "account_disabled",
260 CardActive => "card_active",
261 CardCanceled => "card_canceled",
262 CardExpired => "card_expired",
263 CardInactive => "card_inactive",
264 CardholderBlocked => "cardholder_blocked",
265 CardholderInactive => "cardholder_inactive",
266 CardholderVerificationRequired => "cardholder_verification_required",
267 InsecureAuthorizationMethod => "insecure_authorization_method",
268 InsufficientFunds => "insufficient_funds",
269 NetworkFallback => "network_fallback",
270 NotAllowed => "not_allowed",
271 PinBlocked => "pin_blocked",
272 SpendingControls => "spending_controls",
273 StripeInternalError => "stripe_internal_error",
274 SuspectedFraud => "suspected_fraud",
275 VerificationFailed => "verification_failed",
276 WebhookApproved => "webhook_approved",
277 WebhookDeclined => "webhook_declined",
278 WebhookError => "webhook_error",
279 WebhookTimeout => "webhook_timeout",
280 Unknown(v) => v,
281 }
282 }
283}
284
285impl std::str::FromStr for IssuingAuthorizationRequestReason {
286 type Err = std::convert::Infallible;
287 fn from_str(s: &str) -> Result<Self, Self::Err> {
288 use IssuingAuthorizationRequestReason::*;
289 match s {
290 "account_disabled" => Ok(AccountDisabled),
291 "card_active" => Ok(CardActive),
292 "card_canceled" => Ok(CardCanceled),
293 "card_expired" => Ok(CardExpired),
294 "card_inactive" => Ok(CardInactive),
295 "cardholder_blocked" => Ok(CardholderBlocked),
296 "cardholder_inactive" => Ok(CardholderInactive),
297 "cardholder_verification_required" => Ok(CardholderVerificationRequired),
298 "insecure_authorization_method" => Ok(InsecureAuthorizationMethod),
299 "insufficient_funds" => Ok(InsufficientFunds),
300 "network_fallback" => Ok(NetworkFallback),
301 "not_allowed" => Ok(NotAllowed),
302 "pin_blocked" => Ok(PinBlocked),
303 "spending_controls" => Ok(SpendingControls),
304 "stripe_internal_error" => Ok(StripeInternalError),
305 "suspected_fraud" => Ok(SuspectedFraud),
306 "verification_failed" => Ok(VerificationFailed),
307 "webhook_approved" => Ok(WebhookApproved),
308 "webhook_declined" => Ok(WebhookDeclined),
309 "webhook_error" => Ok(WebhookError),
310 "webhook_timeout" => Ok(WebhookTimeout),
311 v => {
312 tracing::warn!(
313 "Unknown value '{}' for enum '{}'",
314 v,
315 "IssuingAuthorizationRequestReason"
316 );
317 Ok(Unknown(v.to_owned()))
318 }
319 }
320 }
321}
322impl std::fmt::Display for IssuingAuthorizationRequestReason {
323 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
324 f.write_str(self.as_str())
325 }
326}
327
328#[cfg(not(feature = "redact-generated-debug"))]
329impl std::fmt::Debug for IssuingAuthorizationRequestReason {
330 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
331 f.write_str(self.as_str())
332 }
333}
334#[cfg(feature = "redact-generated-debug")]
335impl std::fmt::Debug for IssuingAuthorizationRequestReason {
336 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
337 f.debug_struct(stringify!(IssuingAuthorizationRequestReason)).finish_non_exhaustive()
338 }
339}
340#[cfg(feature = "serialize")]
341impl serde::Serialize for IssuingAuthorizationRequestReason {
342 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
343 where
344 S: serde::Serializer,
345 {
346 serializer.serialize_str(self.as_str())
347 }
348}
349impl miniserde::Deserialize for IssuingAuthorizationRequestReason {
350 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
351 crate::Place::new(out)
352 }
353}
354
355impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationRequestReason> {
356 fn string(&mut self, s: &str) -> miniserde::Result<()> {
357 use std::str::FromStr;
358 self.out = Some(IssuingAuthorizationRequestReason::from_str(s).expect("infallible"));
359 Ok(())
360 }
361}
362
363stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationRequestReason);
364#[cfg(feature = "deserialize")]
365impl<'de> serde::Deserialize<'de> for IssuingAuthorizationRequestReason {
366 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
367 use std::str::FromStr;
368 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
369 Ok(Self::from_str(&s).expect("infallible"))
370 }
371}