stripe_shared/
issuing_authorization_pending_request.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct IssuingAuthorizationPendingRequest {
5    /// The additional amount Stripe will hold if the authorization is approved, in the card's [currency](https://stripe.com/docs/api#issuing_authorization_object-pending-request-currency) and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
6    pub amount: i64,
7    /// Detailed breakdown of amount components.
8    /// These amounts are denominated in `currency` and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
9    pub amount_details: Option<stripe_shared::IssuingAuthorizationAmountDetails>,
10    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
11    /// Must be a [supported currency](https://stripe.com/docs/currencies).
12    pub currency: stripe_types::Currency,
13    /// If set `true`, you may provide [amount](https://stripe.com/docs/api/issuing/authorizations/approve#approve_issuing_authorization-amount) to control how much to hold for the authorization.
14    pub is_amount_controllable: bool,
15    /// The amount the merchant is requesting to be authorized in the `merchant_currency`.
16    /// The amount is in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
17    pub merchant_amount: i64,
18    /// The local currency the merchant is requesting to authorize.
19    pub merchant_currency: stripe_types::Currency,
20    /// The card network's estimate of the likelihood that an authorization is fraudulent.
21    /// Takes on values between 1 and 99.
22    pub network_risk_score: Option<i64>,
23}
24#[doc(hidden)]
25pub struct IssuingAuthorizationPendingRequestBuilder {
26    amount: Option<i64>,
27    amount_details: Option<Option<stripe_shared::IssuingAuthorizationAmountDetails>>,
28    currency: Option<stripe_types::Currency>,
29    is_amount_controllable: Option<bool>,
30    merchant_amount: Option<i64>,
31    merchant_currency: Option<stripe_types::Currency>,
32    network_risk_score: Option<Option<i64>>,
33}
34
35#[allow(
36    unused_variables,
37    irrefutable_let_patterns,
38    clippy::let_unit_value,
39    clippy::match_single_binding,
40    clippy::single_match
41)]
42const _: () = {
43    use miniserde::de::{Map, Visitor};
44    use miniserde::json::Value;
45    use miniserde::{Deserialize, Result, make_place};
46    use stripe_types::miniserde_helpers::FromValueOpt;
47    use stripe_types::{MapBuilder, ObjectDeser};
48
49    make_place!(Place);
50
51    impl Deserialize for IssuingAuthorizationPendingRequest {
52        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
53            Place::new(out)
54        }
55    }
56
57    struct Builder<'a> {
58        out: &'a mut Option<IssuingAuthorizationPendingRequest>,
59        builder: IssuingAuthorizationPendingRequestBuilder,
60    }
61
62    impl Visitor for Place<IssuingAuthorizationPendingRequest> {
63        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
64            Ok(Box::new(Builder {
65                out: &mut self.out,
66                builder: IssuingAuthorizationPendingRequestBuilder::deser_default(),
67            }))
68        }
69    }
70
71    impl MapBuilder for IssuingAuthorizationPendingRequestBuilder {
72        type Out = IssuingAuthorizationPendingRequest;
73        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
74            Ok(match k {
75                "amount" => Deserialize::begin(&mut self.amount),
76                "amount_details" => Deserialize::begin(&mut self.amount_details),
77                "currency" => Deserialize::begin(&mut self.currency),
78                "is_amount_controllable" => Deserialize::begin(&mut self.is_amount_controllable),
79                "merchant_amount" => Deserialize::begin(&mut self.merchant_amount),
80                "merchant_currency" => Deserialize::begin(&mut self.merchant_currency),
81                "network_risk_score" => Deserialize::begin(&mut self.network_risk_score),
82                _ => <dyn Visitor>::ignore(),
83            })
84        }
85
86        fn deser_default() -> Self {
87            Self {
88                amount: Deserialize::default(),
89                amount_details: Deserialize::default(),
90                currency: Deserialize::default(),
91                is_amount_controllable: Deserialize::default(),
92                merchant_amount: Deserialize::default(),
93                merchant_currency: Deserialize::default(),
94                network_risk_score: Deserialize::default(),
95            }
96        }
97
98        fn take_out(&mut self) -> Option<Self::Out> {
99            let (
100                Some(amount),
101                Some(amount_details),
102                Some(currency),
103                Some(is_amount_controllable),
104                Some(merchant_amount),
105                Some(merchant_currency),
106                Some(network_risk_score),
107            ) = (
108                self.amount,
109                self.amount_details,
110                self.currency.take(),
111                self.is_amount_controllable,
112                self.merchant_amount,
113                self.merchant_currency.take(),
114                self.network_risk_score,
115            )
116            else {
117                return None;
118            };
119            Some(Self::Out {
120                amount,
121                amount_details,
122                currency,
123                is_amount_controllable,
124                merchant_amount,
125                merchant_currency,
126                network_risk_score,
127            })
128        }
129    }
130
131    impl Map for Builder<'_> {
132        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
133            self.builder.key(k)
134        }
135
136        fn finish(&mut self) -> Result<()> {
137            *self.out = self.builder.take_out();
138            Ok(())
139        }
140    }
141
142    impl ObjectDeser for IssuingAuthorizationPendingRequest {
143        type Builder = IssuingAuthorizationPendingRequestBuilder;
144    }
145
146    impl FromValueOpt for IssuingAuthorizationPendingRequest {
147        fn from_value(v: Value) -> Option<Self> {
148            let Value::Object(obj) = v else {
149                return None;
150            };
151            let mut b = IssuingAuthorizationPendingRequestBuilder::deser_default();
152            for (k, v) in obj {
153                match k.as_str() {
154                    "amount" => b.amount = FromValueOpt::from_value(v),
155                    "amount_details" => b.amount_details = FromValueOpt::from_value(v),
156                    "currency" => b.currency = FromValueOpt::from_value(v),
157                    "is_amount_controllable" => {
158                        b.is_amount_controllable = FromValueOpt::from_value(v)
159                    }
160                    "merchant_amount" => b.merchant_amount = FromValueOpt::from_value(v),
161                    "merchant_currency" => b.merchant_currency = FromValueOpt::from_value(v),
162                    "network_risk_score" => b.network_risk_score = FromValueOpt::from_value(v),
163                    _ => {}
164                }
165            }
166            b.take_out()
167        }
168    }
169};