stripe_shared/
issuing_authorization_pending_request.rs

1#[derive(Copy, 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::{make_place, Deserialize, Result};
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
83                _ => <dyn Visitor>::ignore(),
84            })
85        }
86
87        fn deser_default() -> Self {
88            Self {
89                amount: Deserialize::default(),
90                amount_details: Deserialize::default(),
91                currency: Deserialize::default(),
92                is_amount_controllable: Deserialize::default(),
93                merchant_amount: Deserialize::default(),
94                merchant_currency: Deserialize::default(),
95                network_risk_score: Deserialize::default(),
96            }
97        }
98
99        fn take_out(&mut self) -> Option<Self::Out> {
100            let (
101                Some(amount),
102                Some(amount_details),
103                Some(currency),
104                Some(is_amount_controllable),
105                Some(merchant_amount),
106                Some(merchant_currency),
107                Some(network_risk_score),
108            ) = (
109                self.amount,
110                self.amount_details,
111                self.currency,
112                self.is_amount_controllable,
113                self.merchant_amount,
114                self.merchant_currency,
115                self.network_risk_score,
116            )
117            else {
118                return None;
119            };
120            Some(Self::Out {
121                amount,
122                amount_details,
123                currency,
124                is_amount_controllable,
125                merchant_amount,
126                merchant_currency,
127                network_risk_score,
128            })
129        }
130    }
131
132    impl<'a> Map for Builder<'a> {
133        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
134            self.builder.key(k)
135        }
136
137        fn finish(&mut self) -> Result<()> {
138            *self.out = self.builder.take_out();
139            Ok(())
140        }
141    }
142
143    impl ObjectDeser for IssuingAuthorizationPendingRequest {
144        type Builder = IssuingAuthorizationPendingRequestBuilder;
145    }
146
147    impl FromValueOpt for IssuingAuthorizationPendingRequest {
148        fn from_value(v: Value) -> Option<Self> {
149            let Value::Object(obj) = v else {
150                return None;
151            };
152            let mut b = IssuingAuthorizationPendingRequestBuilder::deser_default();
153            for (k, v) in obj {
154                match k.as_str() {
155                    "amount" => b.amount = FromValueOpt::from_value(v),
156                    "amount_details" => b.amount_details = FromValueOpt::from_value(v),
157                    "currency" => b.currency = FromValueOpt::from_value(v),
158                    "is_amount_controllable" => {
159                        b.is_amount_controllable = FromValueOpt::from_value(v)
160                    }
161                    "merchant_amount" => b.merchant_amount = FromValueOpt::from_value(v),
162                    "merchant_currency" => b.merchant_currency = FromValueOpt::from_value(v),
163                    "network_risk_score" => b.network_risk_score = FromValueOpt::from_value(v),
164
165                    _ => {}
166                }
167            }
168            b.take_out()
169        }
170    }
171};