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::{make_place, Deserialize, Result};
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
97                _ => <dyn Visitor>::ignore(),
98            })
99        }
100
101        fn deser_default() -> Self {
102            Self {
103                category: Deserialize::default(),
104                category_code: Deserialize::default(),
105                city: Deserialize::default(),
106                country: Deserialize::default(),
107                name: Deserialize::default(),
108                network_id: Deserialize::default(),
109                postal_code: Deserialize::default(),
110                state: Deserialize::default(),
111                tax_id: Deserialize::default(),
112                terminal_id: Deserialize::default(),
113                url: Deserialize::default(),
114            }
115        }
116
117        fn take_out(&mut self) -> Option<Self::Out> {
118            let (
119                Some(category),
120                Some(category_code),
121                Some(city),
122                Some(country),
123                Some(name),
124                Some(network_id),
125                Some(postal_code),
126                Some(state),
127                Some(tax_id),
128                Some(terminal_id),
129                Some(url),
130            ) = (
131                self.category.take(),
132                self.category_code.take(),
133                self.city.take(),
134                self.country.take(),
135                self.name.take(),
136                self.network_id.take(),
137                self.postal_code.take(),
138                self.state.take(),
139                self.tax_id.take(),
140                self.terminal_id.take(),
141                self.url.take(),
142            )
143            else {
144                return None;
145            };
146            Some(Self::Out {
147                category,
148                category_code,
149                city,
150                country,
151                name,
152                network_id,
153                postal_code,
154                state,
155                tax_id,
156                terminal_id,
157                url,
158            })
159        }
160    }
161
162    impl<'a> Map for Builder<'a> {
163        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
164            self.builder.key(k)
165        }
166
167        fn finish(&mut self) -> Result<()> {
168            *self.out = self.builder.take_out();
169            Ok(())
170        }
171    }
172
173    impl ObjectDeser for IssuingAuthorizationMerchantData {
174        type Builder = IssuingAuthorizationMerchantDataBuilder;
175    }
176
177    impl FromValueOpt for IssuingAuthorizationMerchantData {
178        fn from_value(v: Value) -> Option<Self> {
179            let Value::Object(obj) = v else {
180                return None;
181            };
182            let mut b = IssuingAuthorizationMerchantDataBuilder::deser_default();
183            for (k, v) in obj {
184                match k.as_str() {
185                    "category" => b.category = FromValueOpt::from_value(v),
186                    "category_code" => b.category_code = FromValueOpt::from_value(v),
187                    "city" => b.city = FromValueOpt::from_value(v),
188                    "country" => b.country = FromValueOpt::from_value(v),
189                    "name" => b.name = FromValueOpt::from_value(v),
190                    "network_id" => b.network_id = FromValueOpt::from_value(v),
191                    "postal_code" => b.postal_code = FromValueOpt::from_value(v),
192                    "state" => b.state = FromValueOpt::from_value(v),
193                    "tax_id" => b.tax_id = FromValueOpt::from_value(v),
194                    "terminal_id" => b.terminal_id = FromValueOpt::from_value(v),
195                    "url" => b.url = FromValueOpt::from_value(v),
196
197                    _ => {}
198                }
199            }
200            b.take_out()
201        }
202    }
203};