stripe_shared/
issuing_authorization_merchant_data.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct IssuingAuthorizationMerchantData {
5    /// A categorization of the seller's type of business.
6    /// See our [merchant categories guide](https://stripe.com/docs/issuing/merchant-categories) for a list of possible values.
7    pub category: String,
8    /// The merchant category code for the seller’s business
9    pub category_code: String,
10    /// City where the seller is located
11    pub city: Option<String>,
12    /// Country where the seller is located
13    pub country: Option<String>,
14    /// Name of the seller
15    pub name: Option<String>,
16    /// Identifier assigned to the seller by the card network.
17    /// Different card networks may assign different network_id fields to the same merchant.
18    pub network_id: String,
19    /// Postal code where the seller is located
20    pub postal_code: Option<String>,
21    /// State where the seller is located
22    pub state: Option<String>,
23    /// The seller's tax identification number. Currently populated for French merchants only.
24    pub tax_id: Option<String>,
25    /// An ID assigned by the seller to the location of the sale.
26    pub terminal_id: Option<String>,
27    /// URL provided by the merchant on a 3DS request
28    pub url: Option<String>,
29}
30#[doc(hidden)]
31pub struct IssuingAuthorizationMerchantDataBuilder {
32    category: Option<String>,
33    category_code: Option<String>,
34    city: Option<Option<String>>,
35    country: Option<Option<String>>,
36    name: Option<Option<String>>,
37    network_id: Option<String>,
38    postal_code: Option<Option<String>>,
39    state: Option<Option<String>>,
40    tax_id: Option<Option<String>>,
41    terminal_id: Option<Option<String>>,
42    url: Option<Option<String>>,
43}
44
45#[allow(
46    unused_variables,
47    irrefutable_let_patterns,
48    clippy::let_unit_value,
49    clippy::match_single_binding,
50    clippy::single_match
51)]
52const _: () = {
53    use miniserde::de::{Map, Visitor};
54    use miniserde::json::Value;
55    use miniserde::{Deserialize, Result, make_place};
56    use stripe_types::miniserde_helpers::FromValueOpt;
57    use stripe_types::{MapBuilder, ObjectDeser};
58
59    make_place!(Place);
60
61    impl Deserialize for IssuingAuthorizationMerchantData {
62        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
63            Place::new(out)
64        }
65    }
66
67    struct Builder<'a> {
68        out: &'a mut Option<IssuingAuthorizationMerchantData>,
69        builder: IssuingAuthorizationMerchantDataBuilder,
70    }
71
72    impl Visitor for Place<IssuingAuthorizationMerchantData> {
73        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
74            Ok(Box::new(Builder {
75                out: &mut self.out,
76                builder: IssuingAuthorizationMerchantDataBuilder::deser_default(),
77            }))
78        }
79    }
80
81    impl MapBuilder for IssuingAuthorizationMerchantDataBuilder {
82        type Out = IssuingAuthorizationMerchantData;
83        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
84            Ok(match k {
85                "category" => Deserialize::begin(&mut self.category),
86                "category_code" => Deserialize::begin(&mut self.category_code),
87                "city" => Deserialize::begin(&mut self.city),
88                "country" => Deserialize::begin(&mut self.country),
89                "name" => Deserialize::begin(&mut self.name),
90                "network_id" => Deserialize::begin(&mut self.network_id),
91                "postal_code" => Deserialize::begin(&mut self.postal_code),
92                "state" => Deserialize::begin(&mut self.state),
93                "tax_id" => Deserialize::begin(&mut self.tax_id),
94                "terminal_id" => Deserialize::begin(&mut self.terminal_id),
95                "url" => Deserialize::begin(&mut self.url),
96                _ => <dyn Visitor>::ignore(),
97            })
98        }
99
100        fn deser_default() -> Self {
101            Self {
102                category: Deserialize::default(),
103                category_code: Deserialize::default(),
104                city: Deserialize::default(),
105                country: Deserialize::default(),
106                name: Deserialize::default(),
107                network_id: Deserialize::default(),
108                postal_code: Deserialize::default(),
109                state: Deserialize::default(),
110                tax_id: Deserialize::default(),
111                terminal_id: Deserialize::default(),
112                url: Deserialize::default(),
113            }
114        }
115
116        fn take_out(&mut self) -> Option<Self::Out> {
117            let (
118                Some(category),
119                Some(category_code),
120                Some(city),
121                Some(country),
122                Some(name),
123                Some(network_id),
124                Some(postal_code),
125                Some(state),
126                Some(tax_id),
127                Some(terminal_id),
128                Some(url),
129            ) = (
130                self.category.take(),
131                self.category_code.take(),
132                self.city.take(),
133                self.country.take(),
134                self.name.take(),
135                self.network_id.take(),
136                self.postal_code.take(),
137                self.state.take(),
138                self.tax_id.take(),
139                self.terminal_id.take(),
140                self.url.take(),
141            )
142            else {
143                return None;
144            };
145            Some(Self::Out {
146                category,
147                category_code,
148                city,
149                country,
150                name,
151                network_id,
152                postal_code,
153                state,
154                tax_id,
155                terminal_id,
156                url,
157            })
158        }
159    }
160
161    impl Map for Builder<'_> {
162        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
163            self.builder.key(k)
164        }
165
166        fn finish(&mut self) -> Result<()> {
167            *self.out = self.builder.take_out();
168            Ok(())
169        }
170    }
171
172    impl ObjectDeser for IssuingAuthorizationMerchantData {
173        type Builder = IssuingAuthorizationMerchantDataBuilder;
174    }
175
176    impl FromValueOpt for IssuingAuthorizationMerchantData {
177        fn from_value(v: Value) -> Option<Self> {
178            let Value::Object(obj) = v else {
179                return None;
180            };
181            let mut b = IssuingAuthorizationMerchantDataBuilder::deser_default();
182            for (k, v) in obj {
183                match k.as_str() {
184                    "category" => b.category = FromValueOpt::from_value(v),
185                    "category_code" => b.category_code = FromValueOpt::from_value(v),
186                    "city" => b.city = FromValueOpt::from_value(v),
187                    "country" => b.country = FromValueOpt::from_value(v),
188                    "name" => b.name = FromValueOpt::from_value(v),
189                    "network_id" => b.network_id = FromValueOpt::from_value(v),
190                    "postal_code" => b.postal_code = FromValueOpt::from_value(v),
191                    "state" => b.state = FromValueOpt::from_value(v),
192                    "tax_id" => b.tax_id = FromValueOpt::from_value(v),
193                    "terminal_id" => b.terminal_id = FromValueOpt::from_value(v),
194                    "url" => b.url = FromValueOpt::from_value(v),
195                    _ => {}
196                }
197            }
198            b.take_out()
199        }
200    }
201};