stripe_shared/
person_relationship.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PersonRelationship {
5    /// Whether the person is the authorizer of the account's representative.
6    pub authorizer: Option<bool>,
7    /// Whether the person is a director of the account's legal entity.
8    /// Directors are typically members of the governing board of the company, or responsible for ensuring the company meets its regulatory obligations.
9    pub director: Option<bool>,
10    /// Whether the person has significant responsibility to control, manage, or direct the organization.
11    pub executive: Option<bool>,
12    /// Whether the person is the legal guardian of the account's representative.
13    pub legal_guardian: Option<bool>,
14    /// Whether the person is an owner of the account’s legal entity.
15    pub owner: Option<bool>,
16    /// The percent owned by the person of the account's legal entity.
17    pub percent_ownership: Option<f64>,
18    /// Whether the person is authorized as the primary representative of the account.
19    /// This is the person nominated by the business to provide information about themselves, and general information about the account.
20    /// There can only be one representative at any given time.
21    /// At the time the account is created, this person should be set to the person responsible for opening the account.
22    pub representative: Option<bool>,
23    /// The person's title (e.g., CEO, Support Engineer).
24    pub title: Option<String>,
25}
26#[doc(hidden)]
27pub struct PersonRelationshipBuilder {
28    authorizer: Option<Option<bool>>,
29    director: Option<Option<bool>>,
30    executive: Option<Option<bool>>,
31    legal_guardian: Option<Option<bool>>,
32    owner: Option<Option<bool>>,
33    percent_ownership: Option<Option<f64>>,
34    representative: Option<Option<bool>>,
35    title: Option<Option<String>>,
36}
37
38#[allow(
39    unused_variables,
40    irrefutable_let_patterns,
41    clippy::let_unit_value,
42    clippy::match_single_binding,
43    clippy::single_match
44)]
45const _: () = {
46    use miniserde::de::{Map, Visitor};
47    use miniserde::json::Value;
48    use miniserde::{Deserialize, Result, make_place};
49    use stripe_types::miniserde_helpers::FromValueOpt;
50    use stripe_types::{MapBuilder, ObjectDeser};
51
52    make_place!(Place);
53
54    impl Deserialize for PersonRelationship {
55        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
56            Place::new(out)
57        }
58    }
59
60    struct Builder<'a> {
61        out: &'a mut Option<PersonRelationship>,
62        builder: PersonRelationshipBuilder,
63    }
64
65    impl Visitor for Place<PersonRelationship> {
66        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
67            Ok(Box::new(Builder {
68                out: &mut self.out,
69                builder: PersonRelationshipBuilder::deser_default(),
70            }))
71        }
72    }
73
74    impl MapBuilder for PersonRelationshipBuilder {
75        type Out = PersonRelationship;
76        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
77            Ok(match k {
78                "authorizer" => Deserialize::begin(&mut self.authorizer),
79                "director" => Deserialize::begin(&mut self.director),
80                "executive" => Deserialize::begin(&mut self.executive),
81                "legal_guardian" => Deserialize::begin(&mut self.legal_guardian),
82                "owner" => Deserialize::begin(&mut self.owner),
83                "percent_ownership" => Deserialize::begin(&mut self.percent_ownership),
84                "representative" => Deserialize::begin(&mut self.representative),
85                "title" => Deserialize::begin(&mut self.title),
86
87                _ => <dyn Visitor>::ignore(),
88            })
89        }
90
91        fn deser_default() -> Self {
92            Self {
93                authorizer: Deserialize::default(),
94                director: Deserialize::default(),
95                executive: Deserialize::default(),
96                legal_guardian: Deserialize::default(),
97                owner: Deserialize::default(),
98                percent_ownership: Deserialize::default(),
99                representative: Deserialize::default(),
100                title: Deserialize::default(),
101            }
102        }
103
104        fn take_out(&mut self) -> Option<Self::Out> {
105            let (
106                Some(authorizer),
107                Some(director),
108                Some(executive),
109                Some(legal_guardian),
110                Some(owner),
111                Some(percent_ownership),
112                Some(representative),
113                Some(title),
114            ) = (
115                self.authorizer,
116                self.director,
117                self.executive,
118                self.legal_guardian,
119                self.owner,
120                self.percent_ownership,
121                self.representative,
122                self.title.take(),
123            )
124            else {
125                return None;
126            };
127            Some(Self::Out {
128                authorizer,
129                director,
130                executive,
131                legal_guardian,
132                owner,
133                percent_ownership,
134                representative,
135                title,
136            })
137        }
138    }
139
140    impl Map for Builder<'_> {
141        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
142            self.builder.key(k)
143        }
144
145        fn finish(&mut self) -> Result<()> {
146            *self.out = self.builder.take_out();
147            Ok(())
148        }
149    }
150
151    impl ObjectDeser for PersonRelationship {
152        type Builder = PersonRelationshipBuilder;
153    }
154
155    impl FromValueOpt for PersonRelationship {
156        fn from_value(v: Value) -> Option<Self> {
157            let Value::Object(obj) = v else {
158                return None;
159            };
160            let mut b = PersonRelationshipBuilder::deser_default();
161            for (k, v) in obj {
162                match k.as_str() {
163                    "authorizer" => b.authorizer = FromValueOpt::from_value(v),
164                    "director" => b.director = FromValueOpt::from_value(v),
165                    "executive" => b.executive = FromValueOpt::from_value(v),
166                    "legal_guardian" => b.legal_guardian = FromValueOpt::from_value(v),
167                    "owner" => b.owner = FromValueOpt::from_value(v),
168                    "percent_ownership" => b.percent_ownership = FromValueOpt::from_value(v),
169                    "representative" => b.representative = FromValueOpt::from_value(v),
170                    "title" => b.title = FromValueOpt::from_value(v),
171
172                    _ => {}
173                }
174            }
175            b.take_out()
176        }
177    }
178};