Skip to main content

stripe_shared/
issuing_authorization_pending_request.rs

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