stripe_shared/
account_monthly_estimated_revenue.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct AccountMonthlyEstimatedRevenue {
5    /// A non-negative integer representing how much to charge in the [smallest currency unit](/currencies#zero-decimal).
6    pub amount: i64,
7    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
8    /// Must be a [supported currency](https://stripe.com/docs/currencies).
9    pub currency: stripe_types::Currency,
10}
11#[doc(hidden)]
12pub struct AccountMonthlyEstimatedRevenueBuilder {
13    amount: Option<i64>,
14    currency: Option<stripe_types::Currency>,
15}
16
17#[allow(
18    unused_variables,
19    irrefutable_let_patterns,
20    clippy::let_unit_value,
21    clippy::match_single_binding,
22    clippy::single_match
23)]
24const _: () = {
25    use miniserde::de::{Map, Visitor};
26    use miniserde::json::Value;
27    use miniserde::{Deserialize, Result, make_place};
28    use stripe_types::miniserde_helpers::FromValueOpt;
29    use stripe_types::{MapBuilder, ObjectDeser};
30
31    make_place!(Place);
32
33    impl Deserialize for AccountMonthlyEstimatedRevenue {
34        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
35            Place::new(out)
36        }
37    }
38
39    struct Builder<'a> {
40        out: &'a mut Option<AccountMonthlyEstimatedRevenue>,
41        builder: AccountMonthlyEstimatedRevenueBuilder,
42    }
43
44    impl Visitor for Place<AccountMonthlyEstimatedRevenue> {
45        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
46            Ok(Box::new(Builder {
47                out: &mut self.out,
48                builder: AccountMonthlyEstimatedRevenueBuilder::deser_default(),
49            }))
50        }
51    }
52
53    impl MapBuilder for AccountMonthlyEstimatedRevenueBuilder {
54        type Out = AccountMonthlyEstimatedRevenue;
55        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
56            Ok(match k {
57                "amount" => Deserialize::begin(&mut self.amount),
58                "currency" => Deserialize::begin(&mut self.currency),
59
60                _ => <dyn Visitor>::ignore(),
61            })
62        }
63
64        fn deser_default() -> Self {
65            Self { amount: Deserialize::default(), currency: Deserialize::default() }
66        }
67
68        fn take_out(&mut self) -> Option<Self::Out> {
69            let (Some(amount), Some(currency)) = (self.amount, self.currency.take()) else {
70                return None;
71            };
72            Some(Self::Out { amount, currency })
73        }
74    }
75
76    impl Map for Builder<'_> {
77        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
78            self.builder.key(k)
79        }
80
81        fn finish(&mut self) -> Result<()> {
82            *self.out = self.builder.take_out();
83            Ok(())
84        }
85    }
86
87    impl ObjectDeser for AccountMonthlyEstimatedRevenue {
88        type Builder = AccountMonthlyEstimatedRevenueBuilder;
89    }
90
91    impl FromValueOpt for AccountMonthlyEstimatedRevenue {
92        fn from_value(v: Value) -> Option<Self> {
93            let Value::Object(obj) = v else {
94                return None;
95            };
96            let mut b = AccountMonthlyEstimatedRevenueBuilder::deser_default();
97            for (k, v) in obj {
98                match k.as_str() {
99                    "amount" => b.amount = FromValueOpt::from_value(v),
100                    "currency" => b.currency = FromValueOpt::from_value(v),
101
102                    _ => {}
103                }
104            }
105            b.take_out()
106        }
107    }
108};