stripe_misc/
financial_connections_account_ownership.rs

1/// Describes a snapshot of the owners of an account at a particular point in time.
2#[derive(Clone, Debug)]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct FinancialConnectionsAccountOwnership {
5    /// Time at which the object was created. Measured in seconds since the Unix epoch.
6    pub created: stripe_types::Timestamp,
7    /// Unique identifier for the object.
8    pub id: stripe_misc::FinancialConnectionsAccountOwnershipId,
9    /// A paginated list of owners for this account.
10    pub owners: stripe_types::List<stripe_misc::FinancialConnectionsAccountOwner>,
11}
12#[doc(hidden)]
13pub struct FinancialConnectionsAccountOwnershipBuilder {
14    created: Option<stripe_types::Timestamp>,
15    id: Option<stripe_misc::FinancialConnectionsAccountOwnershipId>,
16    owners: Option<stripe_types::List<stripe_misc::FinancialConnectionsAccountOwner>>,
17}
18
19#[allow(
20    unused_variables,
21    irrefutable_let_patterns,
22    clippy::let_unit_value,
23    clippy::match_single_binding,
24    clippy::single_match
25)]
26const _: () = {
27    use miniserde::de::{Map, Visitor};
28    use miniserde::json::Value;
29    use miniserde::{Deserialize, Result, make_place};
30    use stripe_types::miniserde_helpers::FromValueOpt;
31    use stripe_types::{MapBuilder, ObjectDeser};
32
33    make_place!(Place);
34
35    impl Deserialize for FinancialConnectionsAccountOwnership {
36        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
37            Place::new(out)
38        }
39    }
40
41    struct Builder<'a> {
42        out: &'a mut Option<FinancialConnectionsAccountOwnership>,
43        builder: FinancialConnectionsAccountOwnershipBuilder,
44    }
45
46    impl Visitor for Place<FinancialConnectionsAccountOwnership> {
47        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
48            Ok(Box::new(Builder {
49                out: &mut self.out,
50                builder: FinancialConnectionsAccountOwnershipBuilder::deser_default(),
51            }))
52        }
53    }
54
55    impl MapBuilder for FinancialConnectionsAccountOwnershipBuilder {
56        type Out = FinancialConnectionsAccountOwnership;
57        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
58            Ok(match k {
59                "created" => Deserialize::begin(&mut self.created),
60                "id" => Deserialize::begin(&mut self.id),
61                "owners" => Deserialize::begin(&mut self.owners),
62
63                _ => <dyn Visitor>::ignore(),
64            })
65        }
66
67        fn deser_default() -> Self {
68            Self {
69                created: Deserialize::default(),
70                id: Deserialize::default(),
71                owners: Deserialize::default(),
72            }
73        }
74
75        fn take_out(&mut self) -> Option<Self::Out> {
76            let (Some(created), Some(id), Some(owners)) =
77                (self.created, self.id.take(), self.owners.take())
78            else {
79                return None;
80            };
81            Some(Self::Out { created, id, owners })
82        }
83    }
84
85    impl Map for Builder<'_> {
86        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
87            self.builder.key(k)
88        }
89
90        fn finish(&mut self) -> Result<()> {
91            *self.out = self.builder.take_out();
92            Ok(())
93        }
94    }
95
96    impl ObjectDeser for FinancialConnectionsAccountOwnership {
97        type Builder = FinancialConnectionsAccountOwnershipBuilder;
98    }
99
100    impl FromValueOpt for FinancialConnectionsAccountOwnership {
101        fn from_value(v: Value) -> Option<Self> {
102            let Value::Object(obj) = v else {
103                return None;
104            };
105            let mut b = FinancialConnectionsAccountOwnershipBuilder::deser_default();
106            for (k, v) in obj {
107                match k.as_str() {
108                    "created" => b.created = FromValueOpt::from_value(v),
109                    "id" => b.id = FromValueOpt::from_value(v),
110                    "owners" => b.owners = FromValueOpt::from_value(v),
111
112                    _ => {}
113                }
114            }
115            b.take_out()
116        }
117    }
118};
119#[cfg(feature = "serialize")]
120impl serde::Serialize for FinancialConnectionsAccountOwnership {
121    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
122        use serde::ser::SerializeStruct;
123        let mut s = s.serialize_struct("FinancialConnectionsAccountOwnership", 4)?;
124        s.serialize_field("created", &self.created)?;
125        s.serialize_field("id", &self.id)?;
126        s.serialize_field("owners", &self.owners)?;
127
128        s.serialize_field("object", "financial_connections.account_ownership")?;
129        s.end()
130    }
131}
132impl stripe_types::Object for FinancialConnectionsAccountOwnership {
133    type Id = stripe_misc::FinancialConnectionsAccountOwnershipId;
134    fn id(&self) -> &Self::Id {
135        &self.id
136    }
137
138    fn into_id(self) -> Self::Id {
139        self.id
140    }
141}
142stripe_types::def_id!(FinancialConnectionsAccountOwnershipId);