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