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(Copy, Clone, Eq, PartialEq)]
110pub enum IssuingPersonalizationDesignRejectionReasonsCardLogo {
111    GeographicLocation,
112    Inappropriate,
113    NetworkName,
114    NonBinaryImage,
115    NonFiatCurrency,
116    Other,
117    OtherEntity,
118    PromotionalMaterial,
119}
120impl IssuingPersonalizationDesignRejectionReasonsCardLogo {
121    pub fn as_str(self) -> &'static str {
122        use IssuingPersonalizationDesignRejectionReasonsCardLogo::*;
123        match self {
124            GeographicLocation => "geographic_location",
125            Inappropriate => "inappropriate",
126            NetworkName => "network_name",
127            NonBinaryImage => "non_binary_image",
128            NonFiatCurrency => "non_fiat_currency",
129            Other => "other",
130            OtherEntity => "other_entity",
131            PromotionalMaterial => "promotional_material",
132        }
133    }
134}
135
136impl std::str::FromStr for IssuingPersonalizationDesignRejectionReasonsCardLogo {
137    type Err = stripe_types::StripeParseError;
138    fn from_str(s: &str) -> Result<Self, Self::Err> {
139        use IssuingPersonalizationDesignRejectionReasonsCardLogo::*;
140        match s {
141            "geographic_location" => Ok(GeographicLocation),
142            "inappropriate" => Ok(Inappropriate),
143            "network_name" => Ok(NetworkName),
144            "non_binary_image" => Ok(NonBinaryImage),
145            "non_fiat_currency" => Ok(NonFiatCurrency),
146            "other" => Ok(Other),
147            "other_entity" => Ok(OtherEntity),
148            "promotional_material" => Ok(PromotionalMaterial),
149            _ => Err(stripe_types::StripeParseError),
150        }
151    }
152}
153impl std::fmt::Display for IssuingPersonalizationDesignRejectionReasonsCardLogo {
154    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
155        f.write_str(self.as_str())
156    }
157}
158
159impl std::fmt::Debug for IssuingPersonalizationDesignRejectionReasonsCardLogo {
160    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
161        f.write_str(self.as_str())
162    }
163}
164#[cfg(feature = "serialize")]
165impl serde::Serialize for IssuingPersonalizationDesignRejectionReasonsCardLogo {
166    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
167    where
168        S: serde::Serializer,
169    {
170        serializer.serialize_str(self.as_str())
171    }
172}
173impl miniserde::Deserialize for IssuingPersonalizationDesignRejectionReasonsCardLogo {
174    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
175        crate::Place::new(out)
176    }
177}
178
179impl miniserde::de::Visitor for crate::Place<IssuingPersonalizationDesignRejectionReasonsCardLogo> {
180    fn string(&mut self, s: &str) -> miniserde::Result<()> {
181        use std::str::FromStr;
182        self.out = Some(
183            IssuingPersonalizationDesignRejectionReasonsCardLogo::from_str(s)
184                .map_err(|_| miniserde::Error)?,
185        );
186        Ok(())
187    }
188}
189
190stripe_types::impl_from_val_with_from_str!(IssuingPersonalizationDesignRejectionReasonsCardLogo);
191#[cfg(feature = "deserialize")]
192impl<'de> serde::Deserialize<'de> for IssuingPersonalizationDesignRejectionReasonsCardLogo {
193    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
194        use std::str::FromStr;
195        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
196        Self::from_str(&s).map_err(|_| {
197            serde::de::Error::custom(
198                "Unknown value for IssuingPersonalizationDesignRejectionReasonsCardLogo",
199            )
200        })
201    }
202}
203/// The reason(s) the carrier text was rejected.
204#[derive(Copy, Clone, Eq, PartialEq)]
205pub enum IssuingPersonalizationDesignRejectionReasonsCarrierText {
206    GeographicLocation,
207    Inappropriate,
208    NetworkName,
209    NonFiatCurrency,
210    Other,
211    OtherEntity,
212    PromotionalMaterial,
213}
214impl IssuingPersonalizationDesignRejectionReasonsCarrierText {
215    pub fn as_str(self) -> &'static str {
216        use IssuingPersonalizationDesignRejectionReasonsCarrierText::*;
217        match self {
218            GeographicLocation => "geographic_location",
219            Inappropriate => "inappropriate",
220            NetworkName => "network_name",
221            NonFiatCurrency => "non_fiat_currency",
222            Other => "other",
223            OtherEntity => "other_entity",
224            PromotionalMaterial => "promotional_material",
225        }
226    }
227}
228
229impl std::str::FromStr for IssuingPersonalizationDesignRejectionReasonsCarrierText {
230    type Err = stripe_types::StripeParseError;
231    fn from_str(s: &str) -> Result<Self, Self::Err> {
232        use IssuingPersonalizationDesignRejectionReasonsCarrierText::*;
233        match s {
234            "geographic_location" => Ok(GeographicLocation),
235            "inappropriate" => Ok(Inappropriate),
236            "network_name" => Ok(NetworkName),
237            "non_fiat_currency" => Ok(NonFiatCurrency),
238            "other" => Ok(Other),
239            "other_entity" => Ok(OtherEntity),
240            "promotional_material" => Ok(PromotionalMaterial),
241            _ => Err(stripe_types::StripeParseError),
242        }
243    }
244}
245impl std::fmt::Display for IssuingPersonalizationDesignRejectionReasonsCarrierText {
246    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
247        f.write_str(self.as_str())
248    }
249}
250
251impl std::fmt::Debug for IssuingPersonalizationDesignRejectionReasonsCarrierText {
252    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
253        f.write_str(self.as_str())
254    }
255}
256#[cfg(feature = "serialize")]
257impl serde::Serialize for IssuingPersonalizationDesignRejectionReasonsCarrierText {
258    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
259    where
260        S: serde::Serializer,
261    {
262        serializer.serialize_str(self.as_str())
263    }
264}
265impl miniserde::Deserialize for IssuingPersonalizationDesignRejectionReasonsCarrierText {
266    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
267        crate::Place::new(out)
268    }
269}
270
271impl miniserde::de::Visitor
272    for crate::Place<IssuingPersonalizationDesignRejectionReasonsCarrierText>
273{
274    fn string(&mut self, s: &str) -> miniserde::Result<()> {
275        use std::str::FromStr;
276        self.out = Some(
277            IssuingPersonalizationDesignRejectionReasonsCarrierText::from_str(s)
278                .map_err(|_| miniserde::Error)?,
279        );
280        Ok(())
281    }
282}
283
284stripe_types::impl_from_val_with_from_str!(IssuingPersonalizationDesignRejectionReasonsCarrierText);
285#[cfg(feature = "deserialize")]
286impl<'de> serde::Deserialize<'de> for IssuingPersonalizationDesignRejectionReasonsCarrierText {
287    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
288        use std::str::FromStr;
289        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
290        Self::from_str(&s).map_err(|_| {
291            serde::de::Error::custom(
292                "Unknown value for IssuingPersonalizationDesignRejectionReasonsCarrierText",
293            )
294        })
295    }
296}