stripe_connect/
connect_embedded_payouts_features.rs

1#[derive(Copy, Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct ConnectEmbeddedPayoutsFeatures {
5    /// Whether Stripe user authentication is disabled.
6    /// This value can only be `true` for accounts where `controller.requirement_collection` is `application` for the account.
7    /// The default value is the opposite of the `external_account_collection` value.
8    /// For example, if you don't set `external_account_collection`, it defaults to `true` and `disable_stripe_user_authentication` defaults to `false`.
9    pub disable_stripe_user_authentication: bool,
10    /// Whether to allow payout schedule to be changed.
11    /// Defaults to `true` when `controller.losses.payments` is set to `stripe` for the account, otherwise `false`.
12    pub edit_payout_schedule: bool,
13    /// Whether external account collection is enabled.
14    /// This feature can only be `false` for accounts where you’re responsible for collecting updated information when requirements are due or change, like Custom accounts.
15    /// The default value for this feature is `true`.
16    pub external_account_collection: bool,
17    /// Whether to allow creation of instant payouts.
18    /// Defaults to `true` when `controller.losses.payments` is set to `stripe` for the account, otherwise `false`.
19    pub instant_payouts: bool,
20    /// Whether to allow creation of standard payouts.
21    /// Defaults to `true` when `controller.losses.payments` is set to `stripe` for the account, otherwise `false`.
22    pub standard_payouts: bool,
23}
24#[doc(hidden)]
25pub struct ConnectEmbeddedPayoutsFeaturesBuilder {
26    disable_stripe_user_authentication: Option<bool>,
27    edit_payout_schedule: Option<bool>,
28    external_account_collection: Option<bool>,
29    instant_payouts: Option<bool>,
30    standard_payouts: Option<bool>,
31}
32
33#[allow(
34    unused_variables,
35    irrefutable_let_patterns,
36    clippy::let_unit_value,
37    clippy::match_single_binding,
38    clippy::single_match
39)]
40const _: () = {
41    use miniserde::de::{Map, Visitor};
42    use miniserde::json::Value;
43    use miniserde::{Deserialize, Result, make_place};
44    use stripe_types::miniserde_helpers::FromValueOpt;
45    use stripe_types::{MapBuilder, ObjectDeser};
46
47    make_place!(Place);
48
49    impl Deserialize for ConnectEmbeddedPayoutsFeatures {
50        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
51            Place::new(out)
52        }
53    }
54
55    struct Builder<'a> {
56        out: &'a mut Option<ConnectEmbeddedPayoutsFeatures>,
57        builder: ConnectEmbeddedPayoutsFeaturesBuilder,
58    }
59
60    impl Visitor for Place<ConnectEmbeddedPayoutsFeatures> {
61        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
62            Ok(Box::new(Builder {
63                out: &mut self.out,
64                builder: ConnectEmbeddedPayoutsFeaturesBuilder::deser_default(),
65            }))
66        }
67    }
68
69    impl MapBuilder for ConnectEmbeddedPayoutsFeaturesBuilder {
70        type Out = ConnectEmbeddedPayoutsFeatures;
71        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
72            Ok(match k {
73                "disable_stripe_user_authentication" => {
74                    Deserialize::begin(&mut self.disable_stripe_user_authentication)
75                }
76                "edit_payout_schedule" => Deserialize::begin(&mut self.edit_payout_schedule),
77                "external_account_collection" => {
78                    Deserialize::begin(&mut self.external_account_collection)
79                }
80                "instant_payouts" => Deserialize::begin(&mut self.instant_payouts),
81                "standard_payouts" => Deserialize::begin(&mut self.standard_payouts),
82
83                _ => <dyn Visitor>::ignore(),
84            })
85        }
86
87        fn deser_default() -> Self {
88            Self {
89                disable_stripe_user_authentication: Deserialize::default(),
90                edit_payout_schedule: Deserialize::default(),
91                external_account_collection: Deserialize::default(),
92                instant_payouts: Deserialize::default(),
93                standard_payouts: Deserialize::default(),
94            }
95        }
96
97        fn take_out(&mut self) -> Option<Self::Out> {
98            let (
99                Some(disable_stripe_user_authentication),
100                Some(edit_payout_schedule),
101                Some(external_account_collection),
102                Some(instant_payouts),
103                Some(standard_payouts),
104            ) = (
105                self.disable_stripe_user_authentication,
106                self.edit_payout_schedule,
107                self.external_account_collection,
108                self.instant_payouts,
109                self.standard_payouts,
110            )
111            else {
112                return None;
113            };
114            Some(Self::Out {
115                disable_stripe_user_authentication,
116                edit_payout_schedule,
117                external_account_collection,
118                instant_payouts,
119                standard_payouts,
120            })
121        }
122    }
123
124    impl Map for Builder<'_> {
125        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
126            self.builder.key(k)
127        }
128
129        fn finish(&mut self) -> Result<()> {
130            *self.out = self.builder.take_out();
131            Ok(())
132        }
133    }
134
135    impl ObjectDeser for ConnectEmbeddedPayoutsFeatures {
136        type Builder = ConnectEmbeddedPayoutsFeaturesBuilder;
137    }
138
139    impl FromValueOpt for ConnectEmbeddedPayoutsFeatures {
140        fn from_value(v: Value) -> Option<Self> {
141            let Value::Object(obj) = v else {
142                return None;
143            };
144            let mut b = ConnectEmbeddedPayoutsFeaturesBuilder::deser_default();
145            for (k, v) in obj {
146                match k.as_str() {
147                    "disable_stripe_user_authentication" => {
148                        b.disable_stripe_user_authentication = FromValueOpt::from_value(v)
149                    }
150                    "edit_payout_schedule" => b.edit_payout_schedule = FromValueOpt::from_value(v),
151                    "external_account_collection" => {
152                        b.external_account_collection = FromValueOpt::from_value(v)
153                    }
154                    "instant_payouts" => b.instant_payouts = FromValueOpt::from_value(v),
155                    "standard_payouts" => b.standard_payouts = FromValueOpt::from_value(v),
156
157                    _ => {}
158                }
159            }
160            b.take_out()
161        }
162    }
163};