stripe_shared/
account_business_profile.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct AccountBusinessProfile {
5    /// The applicant's gross annual revenue for its preceding fiscal year.
6    pub annual_revenue: Option<stripe_shared::AccountAnnualRevenue>,
7    /// An estimated upper bound of employees, contractors, vendors, etc.
8    /// currently working for the business.
9    pub estimated_worker_count: Option<u64>,
10    /// [The merchant category code for the account](/connect/setting-mcc).
11    /// MCCs are used to classify businesses based on the goods or services they provide.
12    pub mcc: Option<String>,
13    /// Whether the business is a minority-owned, women-owned, and/or LGBTQI+ -owned business.
14    pub minority_owned_business_designation:
15        Option<Vec<AccountBusinessProfileMinorityOwnedBusinessDesignation>>,
16    pub monthly_estimated_revenue: Option<stripe_shared::AccountMonthlyEstimatedRevenue>,
17    /// The customer-facing business name.
18    pub name: Option<String>,
19    /// Internal-only description of the product sold or service provided by the business.
20    /// It's used by Stripe for risk and underwriting purposes.
21    pub product_description: Option<String>,
22    /// A publicly available mailing address for sending support issues to.
23    pub support_address: Option<stripe_shared::Address>,
24    /// A publicly available email address for sending support issues to.
25    pub support_email: Option<String>,
26    /// A publicly available phone number to call with support issues.
27    pub support_phone: Option<String>,
28    /// A publicly available website for handling support issues.
29    pub support_url: Option<String>,
30    /// The business's publicly available website.
31    pub url: Option<String>,
32}
33#[doc(hidden)]
34pub struct AccountBusinessProfileBuilder {
35    annual_revenue: Option<Option<stripe_shared::AccountAnnualRevenue>>,
36    estimated_worker_count: Option<Option<u64>>,
37    mcc: Option<Option<String>>,
38    minority_owned_business_designation:
39        Option<Option<Vec<AccountBusinessProfileMinorityOwnedBusinessDesignation>>>,
40    monthly_estimated_revenue: Option<Option<stripe_shared::AccountMonthlyEstimatedRevenue>>,
41    name: Option<Option<String>>,
42    product_description: Option<Option<String>>,
43    support_address: Option<Option<stripe_shared::Address>>,
44    support_email: Option<Option<String>>,
45    support_phone: Option<Option<String>>,
46    support_url: Option<Option<String>>,
47    url: Option<Option<String>>,
48}
49
50#[allow(
51    unused_variables,
52    irrefutable_let_patterns,
53    clippy::let_unit_value,
54    clippy::match_single_binding,
55    clippy::single_match
56)]
57const _: () = {
58    use miniserde::de::{Map, Visitor};
59    use miniserde::json::Value;
60    use miniserde::{Deserialize, Result, make_place};
61    use stripe_types::miniserde_helpers::FromValueOpt;
62    use stripe_types::{MapBuilder, ObjectDeser};
63
64    make_place!(Place);
65
66    impl Deserialize for AccountBusinessProfile {
67        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
68            Place::new(out)
69        }
70    }
71
72    struct Builder<'a> {
73        out: &'a mut Option<AccountBusinessProfile>,
74        builder: AccountBusinessProfileBuilder,
75    }
76
77    impl Visitor for Place<AccountBusinessProfile> {
78        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
79            Ok(Box::new(Builder {
80                out: &mut self.out,
81                builder: AccountBusinessProfileBuilder::deser_default(),
82            }))
83        }
84    }
85
86    impl MapBuilder for AccountBusinessProfileBuilder {
87        type Out = AccountBusinessProfile;
88        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
89            Ok(match k {
90                "annual_revenue" => Deserialize::begin(&mut self.annual_revenue),
91                "estimated_worker_count" => Deserialize::begin(&mut self.estimated_worker_count),
92                "mcc" => Deserialize::begin(&mut self.mcc),
93                "minority_owned_business_designation" => {
94                    Deserialize::begin(&mut self.minority_owned_business_designation)
95                }
96                "monthly_estimated_revenue" => {
97                    Deserialize::begin(&mut self.monthly_estimated_revenue)
98                }
99                "name" => Deserialize::begin(&mut self.name),
100                "product_description" => Deserialize::begin(&mut self.product_description),
101                "support_address" => Deserialize::begin(&mut self.support_address),
102                "support_email" => Deserialize::begin(&mut self.support_email),
103                "support_phone" => Deserialize::begin(&mut self.support_phone),
104                "support_url" => Deserialize::begin(&mut self.support_url),
105                "url" => Deserialize::begin(&mut self.url),
106                _ => <dyn Visitor>::ignore(),
107            })
108        }
109
110        fn deser_default() -> Self {
111            Self {
112                annual_revenue: Deserialize::default(),
113                estimated_worker_count: Deserialize::default(),
114                mcc: Deserialize::default(),
115                minority_owned_business_designation: Deserialize::default(),
116                monthly_estimated_revenue: Deserialize::default(),
117                name: Deserialize::default(),
118                product_description: Deserialize::default(),
119                support_address: Deserialize::default(),
120                support_email: Deserialize::default(),
121                support_phone: Deserialize::default(),
122                support_url: Deserialize::default(),
123                url: Deserialize::default(),
124            }
125        }
126
127        fn take_out(&mut self) -> Option<Self::Out> {
128            let (
129                Some(annual_revenue),
130                Some(estimated_worker_count),
131                Some(mcc),
132                Some(minority_owned_business_designation),
133                Some(monthly_estimated_revenue),
134                Some(name),
135                Some(product_description),
136                Some(support_address),
137                Some(support_email),
138                Some(support_phone),
139                Some(support_url),
140                Some(url),
141            ) = (
142                self.annual_revenue.take(),
143                self.estimated_worker_count,
144                self.mcc.take(),
145                self.minority_owned_business_designation.take(),
146                self.monthly_estimated_revenue.take(),
147                self.name.take(),
148                self.product_description.take(),
149                self.support_address.take(),
150                self.support_email.take(),
151                self.support_phone.take(),
152                self.support_url.take(),
153                self.url.take(),
154            )
155            else {
156                return None;
157            };
158            Some(Self::Out {
159                annual_revenue,
160                estimated_worker_count,
161                mcc,
162                minority_owned_business_designation,
163                monthly_estimated_revenue,
164                name,
165                product_description,
166                support_address,
167                support_email,
168                support_phone,
169                support_url,
170                url,
171            })
172        }
173    }
174
175    impl Map for Builder<'_> {
176        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
177            self.builder.key(k)
178        }
179
180        fn finish(&mut self) -> Result<()> {
181            *self.out = self.builder.take_out();
182            Ok(())
183        }
184    }
185
186    impl ObjectDeser for AccountBusinessProfile {
187        type Builder = AccountBusinessProfileBuilder;
188    }
189
190    impl FromValueOpt for AccountBusinessProfile {
191        fn from_value(v: Value) -> Option<Self> {
192            let Value::Object(obj) = v else {
193                return None;
194            };
195            let mut b = AccountBusinessProfileBuilder::deser_default();
196            for (k, v) in obj {
197                match k.as_str() {
198                    "annual_revenue" => b.annual_revenue = FromValueOpt::from_value(v),
199                    "estimated_worker_count" => {
200                        b.estimated_worker_count = FromValueOpt::from_value(v)
201                    }
202                    "mcc" => b.mcc = FromValueOpt::from_value(v),
203                    "minority_owned_business_designation" => {
204                        b.minority_owned_business_designation = FromValueOpt::from_value(v)
205                    }
206                    "monthly_estimated_revenue" => {
207                        b.monthly_estimated_revenue = FromValueOpt::from_value(v)
208                    }
209                    "name" => b.name = FromValueOpt::from_value(v),
210                    "product_description" => b.product_description = FromValueOpt::from_value(v),
211                    "support_address" => b.support_address = FromValueOpt::from_value(v),
212                    "support_email" => b.support_email = FromValueOpt::from_value(v),
213                    "support_phone" => b.support_phone = FromValueOpt::from_value(v),
214                    "support_url" => b.support_url = FromValueOpt::from_value(v),
215                    "url" => b.url = FromValueOpt::from_value(v),
216                    _ => {}
217                }
218            }
219            b.take_out()
220        }
221    }
222};
223/// Whether the business is a minority-owned, women-owned, and/or LGBTQI+ -owned business.
224#[derive(Copy, Clone, Eq, PartialEq)]
225pub enum AccountBusinessProfileMinorityOwnedBusinessDesignation {
226    LgbtqiOwnedBusiness,
227    MinorityOwnedBusiness,
228    NoneOfTheseApply,
229    PreferNotToAnswer,
230    WomenOwnedBusiness,
231}
232impl AccountBusinessProfileMinorityOwnedBusinessDesignation {
233    pub fn as_str(self) -> &'static str {
234        use AccountBusinessProfileMinorityOwnedBusinessDesignation::*;
235        match self {
236            LgbtqiOwnedBusiness => "lgbtqi_owned_business",
237            MinorityOwnedBusiness => "minority_owned_business",
238            NoneOfTheseApply => "none_of_these_apply",
239            PreferNotToAnswer => "prefer_not_to_answer",
240            WomenOwnedBusiness => "women_owned_business",
241        }
242    }
243}
244
245impl std::str::FromStr for AccountBusinessProfileMinorityOwnedBusinessDesignation {
246    type Err = stripe_types::StripeParseError;
247    fn from_str(s: &str) -> Result<Self, Self::Err> {
248        use AccountBusinessProfileMinorityOwnedBusinessDesignation::*;
249        match s {
250            "lgbtqi_owned_business" => Ok(LgbtqiOwnedBusiness),
251            "minority_owned_business" => Ok(MinorityOwnedBusiness),
252            "none_of_these_apply" => Ok(NoneOfTheseApply),
253            "prefer_not_to_answer" => Ok(PreferNotToAnswer),
254            "women_owned_business" => Ok(WomenOwnedBusiness),
255            _ => Err(stripe_types::StripeParseError),
256        }
257    }
258}
259impl std::fmt::Display for AccountBusinessProfileMinorityOwnedBusinessDesignation {
260    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
261        f.write_str(self.as_str())
262    }
263}
264
265impl std::fmt::Debug for AccountBusinessProfileMinorityOwnedBusinessDesignation {
266    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
267        f.write_str(self.as_str())
268    }
269}
270#[cfg(feature = "serialize")]
271impl serde::Serialize for AccountBusinessProfileMinorityOwnedBusinessDesignation {
272    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
273    where
274        S: serde::Serializer,
275    {
276        serializer.serialize_str(self.as_str())
277    }
278}
279impl miniserde::Deserialize for AccountBusinessProfileMinorityOwnedBusinessDesignation {
280    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
281        crate::Place::new(out)
282    }
283}
284
285impl miniserde::de::Visitor
286    for crate::Place<AccountBusinessProfileMinorityOwnedBusinessDesignation>
287{
288    fn string(&mut self, s: &str) -> miniserde::Result<()> {
289        use std::str::FromStr;
290        self.out = Some(
291            AccountBusinessProfileMinorityOwnedBusinessDesignation::from_str(s)
292                .map_err(|_| miniserde::Error)?,
293        );
294        Ok(())
295    }
296}
297
298stripe_types::impl_from_val_with_from_str!(AccountBusinessProfileMinorityOwnedBusinessDesignation);
299#[cfg(feature = "deserialize")]
300impl<'de> serde::Deserialize<'de> for AccountBusinessProfileMinorityOwnedBusinessDesignation {
301    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
302        use std::str::FromStr;
303        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
304        Self::from_str(&s).map_err(|_| {
305            serde::de::Error::custom(
306                "Unknown value for AccountBusinessProfileMinorityOwnedBusinessDesignation",
307            )
308        })
309    }
310}