Skip to main content

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