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                _ => <dyn Visitor>::ignore(),
87            })
88        }
89
90        fn deser_default() -> Self {
91            Self {
92                authorizer: Deserialize::default(),
93                director: Deserialize::default(),
94                executive: Deserialize::default(),
95                legal_guardian: Deserialize::default(),
96                owner: Deserialize::default(),
97                percent_ownership: Deserialize::default(),
98                representative: Deserialize::default(),
99                title: Deserialize::default(),
100            }
101        }
102
103        fn take_out(&mut self) -> Option<Self::Out> {
104            let (
105                Some(authorizer),
106                Some(director),
107                Some(executive),
108                Some(legal_guardian),
109                Some(owner),
110                Some(percent_ownership),
111                Some(representative),
112                Some(title),
113            ) = (
114                self.authorizer,
115                self.director,
116                self.executive,
117                self.legal_guardian,
118                self.owner,
119                self.percent_ownership,
120                self.representative,
121                self.title.take(),
122            )
123            else {
124                return None;
125            };
126            Some(Self::Out {
127                authorizer,
128                director,
129                executive,
130                legal_guardian,
131                owner,
132                percent_ownership,
133                representative,
134                title,
135            })
136        }
137    }
138
139    impl Map for Builder<'_> {
140        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
141            self.builder.key(k)
142        }
143
144        fn finish(&mut self) -> Result<()> {
145            *self.out = self.builder.take_out();
146            Ok(())
147        }
148    }
149
150    impl ObjectDeser for PersonRelationship {
151        type Builder = PersonRelationshipBuilder;
152    }
153
154    impl FromValueOpt for PersonRelationship {
155        fn from_value(v: Value) -> Option<Self> {
156            let Value::Object(obj) = v else {
157                return None;
158            };
159            let mut b = PersonRelationshipBuilder::deser_default();
160            for (k, v) in obj {
161                match k.as_str() {
162                    "authorizer" => b.authorizer = FromValueOpt::from_value(v),
163                    "director" => b.director = FromValueOpt::from_value(v),
164                    "executive" => b.executive = FromValueOpt::from_value(v),
165                    "legal_guardian" => b.legal_guardian = FromValueOpt::from_value(v),
166                    "owner" => b.owner = FromValueOpt::from_value(v),
167                    "percent_ownership" => b.percent_ownership = FromValueOpt::from_value(v),
168                    "representative" => b.representative = FromValueOpt::from_value(v),
169                    "title" => b.title = FromValueOpt::from_value(v),
170                    _ => {}
171                }
172            }
173            b.take_out()
174        }
175    }
176};