Skip to main content

stripe_shared/
issuing_authorization_merchant_data.rs

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