stripe_shared/
issuing_personalization_design_rejection_reasons.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct IssuingPersonalizationDesignRejectionReasons {
5    /// The reason(s) the card logo was rejected.
6    pub card_logo: Option<Vec<IssuingPersonalizationDesignRejectionReasonsCardLogo>>,
7    /// The reason(s) the carrier text was rejected.
8    pub carrier_text: Option<Vec<IssuingPersonalizationDesignRejectionReasonsCarrierText>>,
9}
10#[doc(hidden)]
11pub struct IssuingPersonalizationDesignRejectionReasonsBuilder {
12    card_logo: Option<Option<Vec<IssuingPersonalizationDesignRejectionReasonsCardLogo>>>,
13    carrier_text: Option<Option<Vec<IssuingPersonalizationDesignRejectionReasonsCarrierText>>>,
14}
15
16#[allow(
17    unused_variables,
18    irrefutable_let_patterns,
19    clippy::let_unit_value,
20    clippy::match_single_binding,
21    clippy::single_match
22)]
23const _: () = {
24    use miniserde::de::{Map, Visitor};
25    use miniserde::json::Value;
26    use miniserde::{Deserialize, Result, make_place};
27    use stripe_types::miniserde_helpers::FromValueOpt;
28    use stripe_types::{MapBuilder, ObjectDeser};
29
30    make_place!(Place);
31
32    impl Deserialize for IssuingPersonalizationDesignRejectionReasons {
33        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
34            Place::new(out)
35        }
36    }
37
38    struct Builder<'a> {
39        out: &'a mut Option<IssuingPersonalizationDesignRejectionReasons>,
40        builder: IssuingPersonalizationDesignRejectionReasonsBuilder,
41    }
42
43    impl Visitor for Place<IssuingPersonalizationDesignRejectionReasons> {
44        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
45            Ok(Box::new(Builder {
46                out: &mut self.out,
47                builder: IssuingPersonalizationDesignRejectionReasonsBuilder::deser_default(),
48            }))
49        }
50    }
51
52    impl MapBuilder for IssuingPersonalizationDesignRejectionReasonsBuilder {
53        type Out = IssuingPersonalizationDesignRejectionReasons;
54        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
55            Ok(match k {
56                "card_logo" => Deserialize::begin(&mut self.card_logo),
57                "carrier_text" => Deserialize::begin(&mut self.carrier_text),
58                _ => <dyn Visitor>::ignore(),
59            })
60        }
61
62        fn deser_default() -> Self {
63            Self { card_logo: Deserialize::default(), carrier_text: Deserialize::default() }
64        }
65
66        fn take_out(&mut self) -> Option<Self::Out> {
67            let (Some(card_logo), Some(carrier_text)) =
68                (self.card_logo.take(), self.carrier_text.take())
69            else {
70                return None;
71            };
72            Some(Self::Out { card_logo, carrier_text })
73        }
74    }
75
76    impl Map for Builder<'_> {
77        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
78            self.builder.key(k)
79        }
80
81        fn finish(&mut self) -> Result<()> {
82            *self.out = self.builder.take_out();
83            Ok(())
84        }
85    }
86
87    impl ObjectDeser for IssuingPersonalizationDesignRejectionReasons {
88        type Builder = IssuingPersonalizationDesignRejectionReasonsBuilder;
89    }
90
91    impl FromValueOpt for IssuingPersonalizationDesignRejectionReasons {
92        fn from_value(v: Value) -> Option<Self> {
93            let Value::Object(obj) = v else {
94                return None;
95            };
96            let mut b = IssuingPersonalizationDesignRejectionReasonsBuilder::deser_default();
97            for (k, v) in obj {
98                match k.as_str() {
99                    "card_logo" => b.card_logo = FromValueOpt::from_value(v),
100                    "carrier_text" => b.carrier_text = FromValueOpt::from_value(v),
101                    _ => {}
102                }
103            }
104            b.take_out()
105        }
106    }
107};
108/// The reason(s) the card logo was rejected.
109#[derive(Clone, Eq, PartialEq)]
110#[non_exhaustive]
111pub enum IssuingPersonalizationDesignRejectionReasonsCardLogo {
112    GeographicLocation,
113    Inappropriate,
114    NetworkName,
115    NonBinaryImage,
116    NonFiatCurrency,
117    Other,
118    OtherEntity,
119    PromotionalMaterial,
120    /// An unrecognized value from Stripe. Should not be used as a request parameter.
121    Unknown(String),
122}
123impl IssuingPersonalizationDesignRejectionReasonsCardLogo {
124    pub fn as_str(&self) -> &str {
125        use IssuingPersonalizationDesignRejectionReasonsCardLogo::*;
126        match self {
127            GeographicLocation => "geographic_location",
128            Inappropriate => "inappropriate",
129            NetworkName => "network_name",
130            NonBinaryImage => "non_binary_image",
131            NonFiatCurrency => "non_fiat_currency",
132            Other => "other",
133            OtherEntity => "other_entity",
134            PromotionalMaterial => "promotional_material",
135            Unknown(v) => v,
136        }
137    }
138}
139
140impl std::str::FromStr for IssuingPersonalizationDesignRejectionReasonsCardLogo {
141    type Err = std::convert::Infallible;
142    fn from_str(s: &str) -> Result<Self, Self::Err> {
143        use IssuingPersonalizationDesignRejectionReasonsCardLogo::*;
144        match s {
145            "geographic_location" => Ok(GeographicLocation),
146            "inappropriate" => Ok(Inappropriate),
147            "network_name" => Ok(NetworkName),
148            "non_binary_image" => Ok(NonBinaryImage),
149            "non_fiat_currency" => Ok(NonFiatCurrency),
150            "other" => Ok(Other),
151            "other_entity" => Ok(OtherEntity),
152            "promotional_material" => Ok(PromotionalMaterial),
153            v => {
154                tracing::warn!(
155                    "Unknown value '{}' for enum '{}'",
156                    v,
157                    "IssuingPersonalizationDesignRejectionReasonsCardLogo"
158                );
159                Ok(Unknown(v.to_owned()))
160            }
161        }
162    }
163}
164impl std::fmt::Display for IssuingPersonalizationDesignRejectionReasonsCardLogo {
165    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
166        f.write_str(self.as_str())
167    }
168}
169
170impl std::fmt::Debug for IssuingPersonalizationDesignRejectionReasonsCardLogo {
171    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
172        f.write_str(self.as_str())
173    }
174}
175#[cfg(feature = "serialize")]
176impl serde::Serialize for IssuingPersonalizationDesignRejectionReasonsCardLogo {
177    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
178    where
179        S: serde::Serializer,
180    {
181        serializer.serialize_str(self.as_str())
182    }
183}
184impl miniserde::Deserialize for IssuingPersonalizationDesignRejectionReasonsCardLogo {
185    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
186        crate::Place::new(out)
187    }
188}
189
190impl miniserde::de::Visitor for crate::Place<IssuingPersonalizationDesignRejectionReasonsCardLogo> {
191    fn string(&mut self, s: &str) -> miniserde::Result<()> {
192        use std::str::FromStr;
193        self.out = Some(
194            IssuingPersonalizationDesignRejectionReasonsCardLogo::from_str(s).expect("infallible"),
195        );
196        Ok(())
197    }
198}
199
200stripe_types::impl_from_val_with_from_str!(IssuingPersonalizationDesignRejectionReasonsCardLogo);
201#[cfg(feature = "deserialize")]
202impl<'de> serde::Deserialize<'de> for IssuingPersonalizationDesignRejectionReasonsCardLogo {
203    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
204        use std::str::FromStr;
205        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
206        Ok(Self::from_str(&s).expect("infallible"))
207    }
208}
209/// The reason(s) the carrier text was rejected.
210#[derive(Clone, Eq, PartialEq)]
211#[non_exhaustive]
212pub enum IssuingPersonalizationDesignRejectionReasonsCarrierText {
213    GeographicLocation,
214    Inappropriate,
215    NetworkName,
216    NonFiatCurrency,
217    Other,
218    OtherEntity,
219    PromotionalMaterial,
220    /// An unrecognized value from Stripe. Should not be used as a request parameter.
221    Unknown(String),
222}
223impl IssuingPersonalizationDesignRejectionReasonsCarrierText {
224    pub fn as_str(&self) -> &str {
225        use IssuingPersonalizationDesignRejectionReasonsCarrierText::*;
226        match self {
227            GeographicLocation => "geographic_location",
228            Inappropriate => "inappropriate",
229            NetworkName => "network_name",
230            NonFiatCurrency => "non_fiat_currency",
231            Other => "other",
232            OtherEntity => "other_entity",
233            PromotionalMaterial => "promotional_material",
234            Unknown(v) => v,
235        }
236    }
237}
238
239impl std::str::FromStr for IssuingPersonalizationDesignRejectionReasonsCarrierText {
240    type Err = std::convert::Infallible;
241    fn from_str(s: &str) -> Result<Self, Self::Err> {
242        use IssuingPersonalizationDesignRejectionReasonsCarrierText::*;
243        match s {
244            "geographic_location" => Ok(GeographicLocation),
245            "inappropriate" => Ok(Inappropriate),
246            "network_name" => Ok(NetworkName),
247            "non_fiat_currency" => Ok(NonFiatCurrency),
248            "other" => Ok(Other),
249            "other_entity" => Ok(OtherEntity),
250            "promotional_material" => Ok(PromotionalMaterial),
251            v => {
252                tracing::warn!(
253                    "Unknown value '{}' for enum '{}'",
254                    v,
255                    "IssuingPersonalizationDesignRejectionReasonsCarrierText"
256                );
257                Ok(Unknown(v.to_owned()))
258            }
259        }
260    }
261}
262impl std::fmt::Display for IssuingPersonalizationDesignRejectionReasonsCarrierText {
263    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
264        f.write_str(self.as_str())
265    }
266}
267
268impl std::fmt::Debug for IssuingPersonalizationDesignRejectionReasonsCarrierText {
269    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
270        f.write_str(self.as_str())
271    }
272}
273#[cfg(feature = "serialize")]
274impl serde::Serialize for IssuingPersonalizationDesignRejectionReasonsCarrierText {
275    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
276    where
277        S: serde::Serializer,
278    {
279        serializer.serialize_str(self.as_str())
280    }
281}
282impl miniserde::Deserialize for IssuingPersonalizationDesignRejectionReasonsCarrierText {
283    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
284        crate::Place::new(out)
285    }
286}
287
288impl miniserde::de::Visitor
289    for crate::Place<IssuingPersonalizationDesignRejectionReasonsCarrierText>
290{
291    fn string(&mut self, s: &str) -> miniserde::Result<()> {
292        use std::str::FromStr;
293        self.out = Some(
294            IssuingPersonalizationDesignRejectionReasonsCarrierText::from_str(s)
295                .expect("infallible"),
296        );
297        Ok(())
298    }
299}
300
301stripe_types::impl_from_val_with_from_str!(IssuingPersonalizationDesignRejectionReasonsCarrierText);
302#[cfg(feature = "deserialize")]
303impl<'de> serde::Deserialize<'de> for IssuingPersonalizationDesignRejectionReasonsCarrierText {
304    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
305        use std::str::FromStr;
306        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
307        Ok(Self::from_str(&s).expect("infallible"))
308    }
309}