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::{make_place, Deserialize, Result};
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
110 _ => <dyn Visitor>::ignore(),
111 })
112 }
113
114 fn deser_default() -> Self {
115 Self {
116 amount: Deserialize::default(),
117 amount_details: Deserialize::default(),
118 approved: Deserialize::default(),
119 authorization_code: Deserialize::default(),
120 created: Deserialize::default(),
121 currency: Deserialize::default(),
122 merchant_amount: Deserialize::default(),
123 merchant_currency: Deserialize::default(),
124 network_risk_score: Deserialize::default(),
125 reason: Deserialize::default(),
126 reason_message: Deserialize::default(),
127 requested_at: Deserialize::default(),
128 }
129 }
130
131 fn take_out(&mut self) -> Option<Self::Out> {
132 let (
133 Some(amount),
134 Some(amount_details),
135 Some(approved),
136 Some(authorization_code),
137 Some(created),
138 Some(currency),
139 Some(merchant_amount),
140 Some(merchant_currency),
141 Some(network_risk_score),
142 Some(reason),
143 Some(reason_message),
144 Some(requested_at),
145 ) = (
146 self.amount,
147 self.amount_details,
148 self.approved,
149 self.authorization_code.take(),
150 self.created,
151 self.currency,
152 self.merchant_amount,
153 self.merchant_currency,
154 self.network_risk_score,
155 self.reason.take(),
156 self.reason_message.take(),
157 self.requested_at,
158 )
159 else {
160 return None;
161 };
162 Some(Self::Out {
163 amount,
164 amount_details,
165 approved,
166 authorization_code,
167 created,
168 currency,
169 merchant_amount,
170 merchant_currency,
171 network_risk_score,
172 reason,
173 reason_message,
174 requested_at,
175 })
176 }
177 }
178
179 impl<'a> Map for Builder<'a> {
180 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
181 self.builder.key(k)
182 }
183
184 fn finish(&mut self) -> Result<()> {
185 *self.out = self.builder.take_out();
186 Ok(())
187 }
188 }
189
190 impl ObjectDeser for IssuingAuthorizationRequest {
191 type Builder = IssuingAuthorizationRequestBuilder;
192 }
193
194 impl FromValueOpt for IssuingAuthorizationRequest {
195 fn from_value(v: Value) -> Option<Self> {
196 let Value::Object(obj) = v else {
197 return None;
198 };
199 let mut b = IssuingAuthorizationRequestBuilder::deser_default();
200 for (k, v) in obj {
201 match k.as_str() {
202 "amount" => b.amount = FromValueOpt::from_value(v),
203 "amount_details" => b.amount_details = FromValueOpt::from_value(v),
204 "approved" => b.approved = FromValueOpt::from_value(v),
205 "authorization_code" => b.authorization_code = FromValueOpt::from_value(v),
206 "created" => b.created = FromValueOpt::from_value(v),
207 "currency" => b.currency = FromValueOpt::from_value(v),
208 "merchant_amount" => b.merchant_amount = FromValueOpt::from_value(v),
209 "merchant_currency" => b.merchant_currency = FromValueOpt::from_value(v),
210 "network_risk_score" => b.network_risk_score = FromValueOpt::from_value(v),
211 "reason" => b.reason = FromValueOpt::from_value(v),
212 "reason_message" => b.reason_message = FromValueOpt::from_value(v),
213 "requested_at" => b.requested_at = FromValueOpt::from_value(v),
214
215 _ => {}
216 }
217 }
218 b.take_out()
219 }
220 }
221};
222#[derive(Clone, Eq, PartialEq)]
224#[non_exhaustive]
225pub enum IssuingAuthorizationRequestReason {
226 AccountDisabled,
227 CardActive,
228 CardCanceled,
229 CardExpired,
230 CardInactive,
231 CardholderBlocked,
232 CardholderInactive,
233 CardholderVerificationRequired,
234 InsecureAuthorizationMethod,
235 InsufficientFunds,
236 NetworkFallback,
237 NotAllowed,
238 PinBlocked,
239 SpendingControls,
240 SuspectedFraud,
241 VerificationFailed,
242 WebhookApproved,
243 WebhookDeclined,
244 WebhookError,
245 WebhookTimeout,
246 Unknown(String),
248}
249impl IssuingAuthorizationRequestReason {
250 pub fn as_str(&self) -> &str {
251 use IssuingAuthorizationRequestReason::*;
252 match self {
253 AccountDisabled => "account_disabled",
254 CardActive => "card_active",
255 CardCanceled => "card_canceled",
256 CardExpired => "card_expired",
257 CardInactive => "card_inactive",
258 CardholderBlocked => "cardholder_blocked",
259 CardholderInactive => "cardholder_inactive",
260 CardholderVerificationRequired => "cardholder_verification_required",
261 InsecureAuthorizationMethod => "insecure_authorization_method",
262 InsufficientFunds => "insufficient_funds",
263 NetworkFallback => "network_fallback",
264 NotAllowed => "not_allowed",
265 PinBlocked => "pin_blocked",
266 SpendingControls => "spending_controls",
267 SuspectedFraud => "suspected_fraud",
268 VerificationFailed => "verification_failed",
269 WebhookApproved => "webhook_approved",
270 WebhookDeclined => "webhook_declined",
271 WebhookError => "webhook_error",
272 WebhookTimeout => "webhook_timeout",
273 Unknown(v) => v,
274 }
275 }
276}
277
278impl std::str::FromStr for IssuingAuthorizationRequestReason {
279 type Err = std::convert::Infallible;
280 fn from_str(s: &str) -> Result<Self, Self::Err> {
281 use IssuingAuthorizationRequestReason::*;
282 match s {
283 "account_disabled" => Ok(AccountDisabled),
284 "card_active" => Ok(CardActive),
285 "card_canceled" => Ok(CardCanceled),
286 "card_expired" => Ok(CardExpired),
287 "card_inactive" => Ok(CardInactive),
288 "cardholder_blocked" => Ok(CardholderBlocked),
289 "cardholder_inactive" => Ok(CardholderInactive),
290 "cardholder_verification_required" => Ok(CardholderVerificationRequired),
291 "insecure_authorization_method" => Ok(InsecureAuthorizationMethod),
292 "insufficient_funds" => Ok(InsufficientFunds),
293 "network_fallback" => Ok(NetworkFallback),
294 "not_allowed" => Ok(NotAllowed),
295 "pin_blocked" => Ok(PinBlocked),
296 "spending_controls" => Ok(SpendingControls),
297 "suspected_fraud" => Ok(SuspectedFraud),
298 "verification_failed" => Ok(VerificationFailed),
299 "webhook_approved" => Ok(WebhookApproved),
300 "webhook_declined" => Ok(WebhookDeclined),
301 "webhook_error" => Ok(WebhookError),
302 "webhook_timeout" => Ok(WebhookTimeout),
303 v => Ok(Unknown(v.to_owned())),
304 }
305 }
306}
307impl std::fmt::Display for IssuingAuthorizationRequestReason {
308 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
309 f.write_str(self.as_str())
310 }
311}
312
313impl std::fmt::Debug for IssuingAuthorizationRequestReason {
314 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
315 f.write_str(self.as_str())
316 }
317}
318#[cfg(feature = "serialize")]
319impl serde::Serialize for IssuingAuthorizationRequestReason {
320 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
321 where
322 S: serde::Serializer,
323 {
324 serializer.serialize_str(self.as_str())
325 }
326}
327impl miniserde::Deserialize for IssuingAuthorizationRequestReason {
328 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
329 crate::Place::new(out)
330 }
331}
332
333impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationRequestReason> {
334 fn string(&mut self, s: &str) -> miniserde::Result<()> {
335 use std::str::FromStr;
336 self.out = Some(IssuingAuthorizationRequestReason::from_str(s).unwrap());
337 Ok(())
338 }
339}
340
341stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationRequestReason);
342#[cfg(feature = "deserialize")]
343impl<'de> serde::Deserialize<'de> for IssuingAuthorizationRequestReason {
344 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
345 use std::str::FromStr;
346 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
347 Ok(Self::from_str(&s).unwrap())
348 }
349}