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