Skip to main content

stripe_shared/
issuing_personalization_design.rs

1/// A Personalization Design is a logical grouping of a Physical Bundle, card logo, and carrier text that represents a product line.
2#[derive(Clone)]
3#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
4#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
5pub struct IssuingPersonalizationDesign {
6    /// The file for the card logo to use with physical bundles that support card logos.
7    /// Must have a `purpose` value of `issuing_logo`.
8    pub card_logo: Option<stripe_types::Expandable<stripe_shared::File>>,
9    /// Hash containing carrier text, for use with physical bundles that support carrier text.
10    pub carrier_text: Option<stripe_shared::IssuingPersonalizationDesignCarrierText>,
11    /// Time at which the object was created. Measured in seconds since the Unix epoch.
12    pub created: stripe_types::Timestamp,
13    /// Unique identifier for the object.
14    pub id: stripe_shared::IssuingPersonalizationDesignId,
15    /// If the object exists in live mode, the value is `true`.
16    /// If the object exists in test mode, the value is `false`.
17    pub livemode: bool,
18    /// A lookup key used to retrieve personalization designs dynamically from a static string.
19    /// This may be up to 200 characters.
20    pub lookup_key: Option<String>,
21    /// Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object.
22    /// This can be useful for storing additional information about the object in a structured format.
23    pub metadata: std::collections::HashMap<String, String>,
24    /// Friendly display name.
25    pub name: Option<String>,
26    /// The physical bundle object belonging to this personalization design.
27    pub physical_bundle: stripe_types::Expandable<stripe_shared::IssuingPhysicalBundle>,
28    pub preferences: stripe_shared::IssuingPersonalizationDesignPreferences,
29    pub rejection_reasons: stripe_shared::IssuingPersonalizationDesignRejectionReasons,
30    /// Whether this personalization design can be used to create cards.
31    pub status: stripe_shared::IssuingPersonalizationDesignStatus,
32}
33#[cfg(feature = "redact-generated-debug")]
34impl std::fmt::Debug for IssuingPersonalizationDesign {
35    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
36        f.debug_struct("IssuingPersonalizationDesign").finish_non_exhaustive()
37    }
38}
39#[doc(hidden)]
40pub struct IssuingPersonalizationDesignBuilder {
41    card_logo: Option<Option<stripe_types::Expandable<stripe_shared::File>>>,
42    carrier_text: Option<Option<stripe_shared::IssuingPersonalizationDesignCarrierText>>,
43    created: Option<stripe_types::Timestamp>,
44    id: Option<stripe_shared::IssuingPersonalizationDesignId>,
45    livemode: Option<bool>,
46    lookup_key: Option<Option<String>>,
47    metadata: Option<std::collections::HashMap<String, String>>,
48    name: Option<Option<String>>,
49    physical_bundle: Option<stripe_types::Expandable<stripe_shared::IssuingPhysicalBundle>>,
50    preferences: Option<stripe_shared::IssuingPersonalizationDesignPreferences>,
51    rejection_reasons: Option<stripe_shared::IssuingPersonalizationDesignRejectionReasons>,
52    status: Option<stripe_shared::IssuingPersonalizationDesignStatus>,
53}
54
55#[allow(
56    unused_variables,
57    irrefutable_let_patterns,
58    clippy::let_unit_value,
59    clippy::match_single_binding,
60    clippy::single_match
61)]
62const _: () = {
63    use miniserde::de::{Map, Visitor};
64    use miniserde::json::Value;
65    use miniserde::{Deserialize, Result, make_place};
66    use stripe_types::miniserde_helpers::FromValueOpt;
67    use stripe_types::{MapBuilder, ObjectDeser};
68
69    make_place!(Place);
70
71    impl Deserialize for IssuingPersonalizationDesign {
72        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
73            Place::new(out)
74        }
75    }
76
77    struct Builder<'a> {
78        out: &'a mut Option<IssuingPersonalizationDesign>,
79        builder: IssuingPersonalizationDesignBuilder,
80    }
81
82    impl Visitor for Place<IssuingPersonalizationDesign> {
83        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
84            Ok(Box::new(Builder {
85                out: &mut self.out,
86                builder: IssuingPersonalizationDesignBuilder::deser_default(),
87            }))
88        }
89    }
90
91    impl MapBuilder for IssuingPersonalizationDesignBuilder {
92        type Out = IssuingPersonalizationDesign;
93        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
94            Ok(match k {
95                "card_logo" => Deserialize::begin(&mut self.card_logo),
96                "carrier_text" => Deserialize::begin(&mut self.carrier_text),
97                "created" => Deserialize::begin(&mut self.created),
98                "id" => Deserialize::begin(&mut self.id),
99                "livemode" => Deserialize::begin(&mut self.livemode),
100                "lookup_key" => Deserialize::begin(&mut self.lookup_key),
101                "metadata" => Deserialize::begin(&mut self.metadata),
102                "name" => Deserialize::begin(&mut self.name),
103                "physical_bundle" => Deserialize::begin(&mut self.physical_bundle),
104                "preferences" => Deserialize::begin(&mut self.preferences),
105                "rejection_reasons" => Deserialize::begin(&mut self.rejection_reasons),
106                "status" => Deserialize::begin(&mut self.status),
107                _ => <dyn Visitor>::ignore(),
108            })
109        }
110
111        fn deser_default() -> Self {
112            Self {
113                card_logo: Some(None),
114                carrier_text: Some(None),
115                created: None,
116                id: None,
117                livemode: None,
118                lookup_key: Some(None),
119                metadata: None,
120                name: Some(None),
121                physical_bundle: None,
122                preferences: None,
123                rejection_reasons: None,
124                status: None,
125            }
126        }
127
128        fn take_out(&mut self) -> Option<Self::Out> {
129            let (
130                Some(card_logo),
131                Some(carrier_text),
132                Some(created),
133                Some(id),
134                Some(livemode),
135                Some(lookup_key),
136                Some(metadata),
137                Some(name),
138                Some(physical_bundle),
139                Some(preferences),
140                Some(rejection_reasons),
141                Some(status),
142            ) = (
143                self.card_logo.take(),
144                self.carrier_text.take(),
145                self.created,
146                self.id.take(),
147                self.livemode,
148                self.lookup_key.take(),
149                self.metadata.take(),
150                self.name.take(),
151                self.physical_bundle.take(),
152                self.preferences,
153                self.rejection_reasons.take(),
154                self.status.take(),
155            )
156            else {
157                return None;
158            };
159            Some(Self::Out {
160                card_logo,
161                carrier_text,
162                created,
163                id,
164                livemode,
165                lookup_key,
166                metadata,
167                name,
168                physical_bundle,
169                preferences,
170                rejection_reasons,
171                status,
172            })
173        }
174    }
175
176    impl Map for Builder<'_> {
177        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
178            self.builder.key(k)
179        }
180
181        fn finish(&mut self) -> Result<()> {
182            *self.out = self.builder.take_out();
183            Ok(())
184        }
185    }
186
187    impl ObjectDeser for IssuingPersonalizationDesign {
188        type Builder = IssuingPersonalizationDesignBuilder;
189    }
190
191    impl FromValueOpt for IssuingPersonalizationDesign {
192        fn from_value(v: Value) -> Option<Self> {
193            let Value::Object(obj) = v else {
194                return None;
195            };
196            let mut b = IssuingPersonalizationDesignBuilder::deser_default();
197            for (k, v) in obj {
198                match k.as_str() {
199                    "card_logo" => b.card_logo = FromValueOpt::from_value(v),
200                    "carrier_text" => b.carrier_text = FromValueOpt::from_value(v),
201                    "created" => b.created = FromValueOpt::from_value(v),
202                    "id" => b.id = FromValueOpt::from_value(v),
203                    "livemode" => b.livemode = FromValueOpt::from_value(v),
204                    "lookup_key" => b.lookup_key = FromValueOpt::from_value(v),
205                    "metadata" => b.metadata = FromValueOpt::from_value(v),
206                    "name" => b.name = FromValueOpt::from_value(v),
207                    "physical_bundle" => b.physical_bundle = FromValueOpt::from_value(v),
208                    "preferences" => b.preferences = FromValueOpt::from_value(v),
209                    "rejection_reasons" => b.rejection_reasons = FromValueOpt::from_value(v),
210                    "status" => b.status = FromValueOpt::from_value(v),
211                    _ => {}
212                }
213            }
214            b.take_out()
215        }
216    }
217};
218#[cfg(feature = "serialize")]
219impl serde::Serialize for IssuingPersonalizationDesign {
220    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
221        use serde::ser::SerializeStruct;
222        let mut s = s.serialize_struct("IssuingPersonalizationDesign", 13)?;
223        s.serialize_field("card_logo", &self.card_logo)?;
224        s.serialize_field("carrier_text", &self.carrier_text)?;
225        s.serialize_field("created", &self.created)?;
226        s.serialize_field("id", &self.id)?;
227        s.serialize_field("livemode", &self.livemode)?;
228        s.serialize_field("lookup_key", &self.lookup_key)?;
229        s.serialize_field("metadata", &self.metadata)?;
230        s.serialize_field("name", &self.name)?;
231        s.serialize_field("physical_bundle", &self.physical_bundle)?;
232        s.serialize_field("preferences", &self.preferences)?;
233        s.serialize_field("rejection_reasons", &self.rejection_reasons)?;
234        s.serialize_field("status", &self.status)?;
235
236        s.serialize_field("object", "issuing.personalization_design")?;
237        s.end()
238    }
239}
240impl stripe_types::Object for IssuingPersonalizationDesign {
241    type Id = stripe_shared::IssuingPersonalizationDesignId;
242    fn id(&self) -> &Self::Id {
243        &self.id
244    }
245
246    fn into_id(self) -> Self::Id {
247        self.id
248    }
249}
250stripe_types::def_id!(IssuingPersonalizationDesignId);
251#[derive(Clone, Eq, PartialEq)]
252#[non_exhaustive]
253pub enum IssuingPersonalizationDesignStatus {
254    Active,
255    Inactive,
256    Rejected,
257    Review,
258    /// An unrecognized value from Stripe. Should not be used as a request parameter.
259    Unknown(String),
260}
261impl IssuingPersonalizationDesignStatus {
262    pub fn as_str(&self) -> &str {
263        use IssuingPersonalizationDesignStatus::*;
264        match self {
265            Active => "active",
266            Inactive => "inactive",
267            Rejected => "rejected",
268            Review => "review",
269            Unknown(v) => v,
270        }
271    }
272}
273
274impl std::str::FromStr for IssuingPersonalizationDesignStatus {
275    type Err = std::convert::Infallible;
276    fn from_str(s: &str) -> Result<Self, Self::Err> {
277        use IssuingPersonalizationDesignStatus::*;
278        match s {
279            "active" => Ok(Active),
280            "inactive" => Ok(Inactive),
281            "rejected" => Ok(Rejected),
282            "review" => Ok(Review),
283            v => {
284                tracing::warn!(
285                    "Unknown value '{}' for enum '{}'",
286                    v,
287                    "IssuingPersonalizationDesignStatus"
288                );
289                Ok(Unknown(v.to_owned()))
290            }
291        }
292    }
293}
294impl std::fmt::Display for IssuingPersonalizationDesignStatus {
295    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
296        f.write_str(self.as_str())
297    }
298}
299
300#[cfg(not(feature = "redact-generated-debug"))]
301impl std::fmt::Debug for IssuingPersonalizationDesignStatus {
302    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
303        f.write_str(self.as_str())
304    }
305}
306#[cfg(feature = "redact-generated-debug")]
307impl std::fmt::Debug for IssuingPersonalizationDesignStatus {
308    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
309        f.debug_struct(stringify!(IssuingPersonalizationDesignStatus)).finish_non_exhaustive()
310    }
311}
312impl serde::Serialize for IssuingPersonalizationDesignStatus {
313    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
314    where
315        S: serde::Serializer,
316    {
317        serializer.serialize_str(self.as_str())
318    }
319}
320impl miniserde::Deserialize for IssuingPersonalizationDesignStatus {
321    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
322        crate::Place::new(out)
323    }
324}
325
326impl miniserde::de::Visitor for crate::Place<IssuingPersonalizationDesignStatus> {
327    fn string(&mut self, s: &str) -> miniserde::Result<()> {
328        use std::str::FromStr;
329        self.out = Some(IssuingPersonalizationDesignStatus::from_str(s).expect("infallible"));
330        Ok(())
331    }
332}
333
334stripe_types::impl_from_val_with_from_str!(IssuingPersonalizationDesignStatus);
335#[cfg(feature = "deserialize")]
336impl<'de> serde::Deserialize<'de> for IssuingPersonalizationDesignStatus {
337    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
338        use std::str::FromStr;
339        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
340        Ok(Self::from_str(&s).expect("infallible"))
341    }
342}