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