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::{Deserialize, Result, make_place};
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                _ => <dyn Visitor>::ignore(),
100            })
101        }
102
103        fn deser_default() -> Self {
104            Self {
105                card_logo: Deserialize::default(),
106                carrier_text: Deserialize::default(),
107                created: Deserialize::default(),
108                id: Deserialize::default(),
109                livemode: Deserialize::default(),
110                lookup_key: Deserialize::default(),
111                metadata: Deserialize::default(),
112                name: Deserialize::default(),
113                physical_bundle: Deserialize::default(),
114                preferences: Deserialize::default(),
115                rejection_reasons: Deserialize::default(),
116                status: Deserialize::default(),
117            }
118        }
119
120        fn take_out(&mut self) -> Option<Self::Out> {
121            let (
122                Some(card_logo),
123                Some(carrier_text),
124                Some(created),
125                Some(id),
126                Some(livemode),
127                Some(lookup_key),
128                Some(metadata),
129                Some(name),
130                Some(physical_bundle),
131                Some(preferences),
132                Some(rejection_reasons),
133                Some(status),
134            ) = (
135                self.card_logo.take(),
136                self.carrier_text.take(),
137                self.created,
138                self.id.take(),
139                self.livemode,
140                self.lookup_key.take(),
141                self.metadata.take(),
142                self.name.take(),
143                self.physical_bundle.take(),
144                self.preferences,
145                self.rejection_reasons.take(),
146                self.status,
147            )
148            else {
149                return None;
150            };
151            Some(Self::Out {
152                card_logo,
153                carrier_text,
154                created,
155                id,
156                livemode,
157                lookup_key,
158                metadata,
159                name,
160                physical_bundle,
161                preferences,
162                rejection_reasons,
163                status,
164            })
165        }
166    }
167
168    impl Map for Builder<'_> {
169        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
170            self.builder.key(k)
171        }
172
173        fn finish(&mut self) -> Result<()> {
174            *self.out = self.builder.take_out();
175            Ok(())
176        }
177    }
178
179    impl ObjectDeser for IssuingPersonalizationDesign {
180        type Builder = IssuingPersonalizationDesignBuilder;
181    }
182
183    impl FromValueOpt for IssuingPersonalizationDesign {
184        fn from_value(v: Value) -> Option<Self> {
185            let Value::Object(obj) = v else {
186                return None;
187            };
188            let mut b = IssuingPersonalizationDesignBuilder::deser_default();
189            for (k, v) in obj {
190                match k.as_str() {
191                    "card_logo" => b.card_logo = FromValueOpt::from_value(v),
192                    "carrier_text" => b.carrier_text = FromValueOpt::from_value(v),
193                    "created" => b.created = FromValueOpt::from_value(v),
194                    "id" => b.id = FromValueOpt::from_value(v),
195                    "livemode" => b.livemode = FromValueOpt::from_value(v),
196                    "lookup_key" => b.lookup_key = FromValueOpt::from_value(v),
197                    "metadata" => b.metadata = FromValueOpt::from_value(v),
198                    "name" => b.name = FromValueOpt::from_value(v),
199                    "physical_bundle" => b.physical_bundle = FromValueOpt::from_value(v),
200                    "preferences" => b.preferences = FromValueOpt::from_value(v),
201                    "rejection_reasons" => b.rejection_reasons = FromValueOpt::from_value(v),
202                    "status" => b.status = FromValueOpt::from_value(v),
203                    _ => {}
204                }
205            }
206            b.take_out()
207        }
208    }
209};
210#[cfg(feature = "serialize")]
211impl serde::Serialize for IssuingPersonalizationDesign {
212    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
213        use serde::ser::SerializeStruct;
214        let mut s = s.serialize_struct("IssuingPersonalizationDesign", 13)?;
215        s.serialize_field("card_logo", &self.card_logo)?;
216        s.serialize_field("carrier_text", &self.carrier_text)?;
217        s.serialize_field("created", &self.created)?;
218        s.serialize_field("id", &self.id)?;
219        s.serialize_field("livemode", &self.livemode)?;
220        s.serialize_field("lookup_key", &self.lookup_key)?;
221        s.serialize_field("metadata", &self.metadata)?;
222        s.serialize_field("name", &self.name)?;
223        s.serialize_field("physical_bundle", &self.physical_bundle)?;
224        s.serialize_field("preferences", &self.preferences)?;
225        s.serialize_field("rejection_reasons", &self.rejection_reasons)?;
226        s.serialize_field("status", &self.status)?;
227
228        s.serialize_field("object", "issuing.personalization_design")?;
229        s.end()
230    }
231}
232impl stripe_types::Object for IssuingPersonalizationDesign {
233    type Id = stripe_shared::IssuingPersonalizationDesignId;
234    fn id(&self) -> &Self::Id {
235        &self.id
236    }
237
238    fn into_id(self) -> Self::Id {
239        self.id
240    }
241}
242stripe_types::def_id!(IssuingPersonalizationDesignId);
243#[derive(Copy, Clone, Eq, PartialEq)]
244pub enum IssuingPersonalizationDesignStatus {
245    Active,
246    Inactive,
247    Rejected,
248    Review,
249}
250impl IssuingPersonalizationDesignStatus {
251    pub fn as_str(self) -> &'static str {
252        use IssuingPersonalizationDesignStatus::*;
253        match self {
254            Active => "active",
255            Inactive => "inactive",
256            Rejected => "rejected",
257            Review => "review",
258        }
259    }
260}
261
262impl std::str::FromStr for IssuingPersonalizationDesignStatus {
263    type Err = stripe_types::StripeParseError;
264    fn from_str(s: &str) -> Result<Self, Self::Err> {
265        use IssuingPersonalizationDesignStatus::*;
266        match s {
267            "active" => Ok(Active),
268            "inactive" => Ok(Inactive),
269            "rejected" => Ok(Rejected),
270            "review" => Ok(Review),
271            _ => Err(stripe_types::StripeParseError),
272        }
273    }
274}
275impl std::fmt::Display for IssuingPersonalizationDesignStatus {
276    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
277        f.write_str(self.as_str())
278    }
279}
280
281impl std::fmt::Debug for IssuingPersonalizationDesignStatus {
282    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
283        f.write_str(self.as_str())
284    }
285}
286impl serde::Serialize for IssuingPersonalizationDesignStatus {
287    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
288    where
289        S: serde::Serializer,
290    {
291        serializer.serialize_str(self.as_str())
292    }
293}
294impl miniserde::Deserialize for IssuingPersonalizationDesignStatus {
295    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
296        crate::Place::new(out)
297    }
298}
299
300impl miniserde::de::Visitor for crate::Place<IssuingPersonalizationDesignStatus> {
301    fn string(&mut self, s: &str) -> miniserde::Result<()> {
302        use std::str::FromStr;
303        self.out =
304            Some(IssuingPersonalizationDesignStatus::from_str(s).map_err(|_| miniserde::Error)?);
305        Ok(())
306    }
307}
308
309stripe_types::impl_from_val_with_from_str!(IssuingPersonalizationDesignStatus);
310#[cfg(feature = "deserialize")]
311impl<'de> serde::Deserialize<'de> for IssuingPersonalizationDesignStatus {
312    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
313        use std::str::FromStr;
314        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
315        Self::from_str(&s).map_err(|_| {
316            serde::de::Error::custom("Unknown value for IssuingPersonalizationDesignStatus")
317        })
318    }
319}