1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct AccountBusinessProfile {
5 pub annual_revenue: Option<stripe_shared::AccountAnnualRevenue>,
7 pub estimated_worker_count: Option<u64>,
10 pub mcc: Option<String>,
13 pub minority_owned_business_designation:
15 Option<Vec<AccountBusinessProfileMinorityOwnedBusinessDesignation>>,
16 pub monthly_estimated_revenue: Option<stripe_shared::AccountMonthlyEstimatedRevenue>,
17 pub name: Option<String>,
19 pub product_description: Option<String>,
22 pub support_address: Option<stripe_shared::Address>,
24 pub support_email: Option<String>,
26 pub support_phone: Option<String>,
28 pub support_url: Option<String>,
30 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#[derive(Clone, Eq, PartialEq)]
225#[non_exhaustive]
226pub enum AccountBusinessProfileMinorityOwnedBusinessDesignation {
227 LgbtqiOwnedBusiness,
228 MinorityOwnedBusiness,
229 NoneOfTheseApply,
230 PreferNotToAnswer,
231 WomenOwnedBusiness,
232 Unknown(String),
234}
235impl AccountBusinessProfileMinorityOwnedBusinessDesignation {
236 pub fn as_str(&self) -> &str {
237 use AccountBusinessProfileMinorityOwnedBusinessDesignation::*;
238 match self {
239 LgbtqiOwnedBusiness => "lgbtqi_owned_business",
240 MinorityOwnedBusiness => "minority_owned_business",
241 NoneOfTheseApply => "none_of_these_apply",
242 PreferNotToAnswer => "prefer_not_to_answer",
243 WomenOwnedBusiness => "women_owned_business",
244 Unknown(v) => v,
245 }
246 }
247}
248
249impl std::str::FromStr for AccountBusinessProfileMinorityOwnedBusinessDesignation {
250 type Err = std::convert::Infallible;
251 fn from_str(s: &str) -> Result<Self, Self::Err> {
252 use AccountBusinessProfileMinorityOwnedBusinessDesignation::*;
253 match s {
254 "lgbtqi_owned_business" => Ok(LgbtqiOwnedBusiness),
255 "minority_owned_business" => Ok(MinorityOwnedBusiness),
256 "none_of_these_apply" => Ok(NoneOfTheseApply),
257 "prefer_not_to_answer" => Ok(PreferNotToAnswer),
258 "women_owned_business" => Ok(WomenOwnedBusiness),
259 v => {
260 tracing::warn!(
261 "Unknown value '{}' for enum '{}'",
262 v,
263 "AccountBusinessProfileMinorityOwnedBusinessDesignation"
264 );
265 Ok(Unknown(v.to_owned()))
266 }
267 }
268 }
269}
270impl std::fmt::Display for AccountBusinessProfileMinorityOwnedBusinessDesignation {
271 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
272 f.write_str(self.as_str())
273 }
274}
275
276impl std::fmt::Debug for AccountBusinessProfileMinorityOwnedBusinessDesignation {
277 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
278 f.write_str(self.as_str())
279 }
280}
281#[cfg(feature = "serialize")]
282impl serde::Serialize for AccountBusinessProfileMinorityOwnedBusinessDesignation {
283 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
284 where
285 S: serde::Serializer,
286 {
287 serializer.serialize_str(self.as_str())
288 }
289}
290impl miniserde::Deserialize for AccountBusinessProfileMinorityOwnedBusinessDesignation {
291 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
292 crate::Place::new(out)
293 }
294}
295
296impl miniserde::de::Visitor
297 for crate::Place<AccountBusinessProfileMinorityOwnedBusinessDesignation>
298{
299 fn string(&mut self, s: &str) -> miniserde::Result<()> {
300 use std::str::FromStr;
301 self.out = Some(
302 AccountBusinessProfileMinorityOwnedBusinessDesignation::from_str(s)
303 .expect("infallible"),
304 );
305 Ok(())
306 }
307}
308
309stripe_types::impl_from_val_with_from_str!(AccountBusinessProfileMinorityOwnedBusinessDesignation);
310#[cfg(feature = "deserialize")]
311impl<'de> serde::Deserialize<'de> for AccountBusinessProfileMinorityOwnedBusinessDesignation {
312 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
313 use std::str::FromStr;
314 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
315 Ok(Self::from_str(&s).expect("infallible"))
316 }
317}