Skip to main content

stripe_shared/
issuing_card.rs

1/// You can [create physical or virtual cards](https://docs.stripe.com/issuing) that are issued to cardholders.
2///
3/// For more details see <<https://stripe.com/docs/api/issuing/cards/object>>.
4#[derive(Clone)]
5#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
6#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
7pub struct IssuingCard {
8    /// The brand of the card.
9    pub brand: String,
10    /// The reason why the card was canceled.
11    pub cancellation_reason: Option<IssuingCardCancellationReason>,
12    pub cardholder: stripe_shared::IssuingCardholder,
13    /// Time at which the object was created. Measured in seconds since the Unix epoch.
14    pub created: stripe_types::Timestamp,
15    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
16    /// Supported currencies are `usd` in the US, `eur` in the EU, and `gbp` in the UK.
17    pub currency: stripe_types::Currency,
18    /// The card's CVC.
19    /// For security reasons, this is only available for virtual cards, and will be omitted unless you explicitly request it with [the `expand` parameter](https://docs.stripe.com/api/expanding_objects).
20    /// Additionally, it's only available via the ["Retrieve a card" endpoint](https://docs.stripe.com/api/issuing/cards/retrieve), not via "List all cards" or any other endpoint.
21    pub cvc: Option<String>,
22    /// The expiration month of the card.
23    pub exp_month: i64,
24    /// The expiration year of the card.
25    pub exp_year: i64,
26    /// The financial account this card is attached to.
27    pub financial_account: Option<String>,
28    /// Unique identifier for the object.
29    pub id: stripe_shared::IssuingCardId,
30    /// The last 4 digits of the card number.
31    pub last4: String,
32    /// Stripe’s assessment of whether this card’s details have been compromised.
33    /// If this property isn't null, cancel and reissue the card to prevent fraudulent activity risk.
34    pub latest_fraud_warning: Option<stripe_shared::IssuingCardFraudWarning>,
35    /// Rules that control the lifecycle of this card, such as automatic cancellation.
36    /// Refer to our [documentation](/issuing/controls/lifecycle-controls) for more details.
37    pub lifecycle_controls: Option<stripe_shared::IssuingCardLifecycleControls>,
38    /// If the object exists in live mode, the value is `true`.
39    /// If the object exists in test mode, the value is `false`.
40    pub livemode: bool,
41    /// Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object.
42    /// This can be useful for storing additional information about the object in a structured format.
43    pub metadata: std::collections::HashMap<String, String>,
44    /// The full unredacted card number.
45    /// For security reasons, this is only available for virtual cards, and will be omitted unless you explicitly request it with [the `expand` parameter](https://docs.stripe.com/api/expanding_objects).
46    /// Additionally, it's only available via the ["Retrieve a card" endpoint](https://docs.stripe.com/api/issuing/cards/retrieve), not via "List all cards" or any other endpoint.
47    pub number: Option<String>,
48    /// The personalization design object belonging to this card.
49    pub personalization_design:
50        Option<stripe_types::Expandable<stripe_shared::IssuingPersonalizationDesign>>,
51    /// The latest card that replaces this card, if any.
52    pub replaced_by: Option<stripe_types::Expandable<stripe_shared::IssuingCard>>,
53    /// The card this card replaces, if any.
54    pub replacement_for: Option<stripe_types::Expandable<stripe_shared::IssuingCard>>,
55    /// The reason why the previous card needed to be replaced.
56    pub replacement_reason: Option<IssuingCardReplacementReason>,
57    /// Text separate from cardholder name, printed on the card.
58    pub second_line: Option<String>,
59    /// Where and how the card will be shipped.
60    pub shipping: Option<stripe_shared::IssuingCardShipping>,
61    pub spending_controls: stripe_shared::IssuingCardAuthorizationControls,
62    /// Whether authorizations can be approved on this card.
63    /// May be blocked from activating cards depending on past-due Cardholder requirements.
64    /// Defaults to `inactive`.
65    pub status: stripe_shared::IssuingCardStatus,
66    /// The type of the card.
67    #[cfg_attr(feature = "deserialize", serde(rename = "type"))]
68    pub type_: stripe_shared::IssuingCardType,
69    /// Information relating to digital wallets (like Apple Pay and Google Pay).
70    pub wallets: Option<stripe_shared::IssuingCardWallets>,
71}
72#[cfg(feature = "redact-generated-debug")]
73impl std::fmt::Debug for IssuingCard {
74    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
75        f.debug_struct("IssuingCard").finish_non_exhaustive()
76    }
77}
78#[doc(hidden)]
79pub struct IssuingCardBuilder {
80    brand: Option<String>,
81    cancellation_reason: Option<Option<IssuingCardCancellationReason>>,
82    cardholder: Option<stripe_shared::IssuingCardholder>,
83    created: Option<stripe_types::Timestamp>,
84    currency: Option<stripe_types::Currency>,
85    cvc: Option<Option<String>>,
86    exp_month: Option<i64>,
87    exp_year: Option<i64>,
88    financial_account: Option<Option<String>>,
89    id: Option<stripe_shared::IssuingCardId>,
90    last4: Option<String>,
91    latest_fraud_warning: Option<Option<stripe_shared::IssuingCardFraudWarning>>,
92    lifecycle_controls: Option<Option<stripe_shared::IssuingCardLifecycleControls>>,
93    livemode: Option<bool>,
94    metadata: Option<std::collections::HashMap<String, String>>,
95    number: Option<Option<String>>,
96    personalization_design:
97        Option<Option<stripe_types::Expandable<stripe_shared::IssuingPersonalizationDesign>>>,
98    replaced_by: Option<Option<stripe_types::Expandable<stripe_shared::IssuingCard>>>,
99    replacement_for: Option<Option<stripe_types::Expandable<stripe_shared::IssuingCard>>>,
100    replacement_reason: Option<Option<IssuingCardReplacementReason>>,
101    second_line: Option<Option<String>>,
102    shipping: Option<Option<stripe_shared::IssuingCardShipping>>,
103    spending_controls: Option<stripe_shared::IssuingCardAuthorizationControls>,
104    status: Option<stripe_shared::IssuingCardStatus>,
105    type_: Option<stripe_shared::IssuingCardType>,
106    wallets: Option<Option<stripe_shared::IssuingCardWallets>>,
107}
108
109#[allow(
110    unused_variables,
111    irrefutable_let_patterns,
112    clippy::let_unit_value,
113    clippy::match_single_binding,
114    clippy::single_match
115)]
116const _: () = {
117    use miniserde::de::{Map, Visitor};
118    use miniserde::json::Value;
119    use miniserde::{Deserialize, Result, make_place};
120    use stripe_types::miniserde_helpers::FromValueOpt;
121    use stripe_types::{MapBuilder, ObjectDeser};
122
123    make_place!(Place);
124
125    impl Deserialize for IssuingCard {
126        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
127            Place::new(out)
128        }
129    }
130
131    struct Builder<'a> {
132        out: &'a mut Option<IssuingCard>,
133        builder: IssuingCardBuilder,
134    }
135
136    impl Visitor for Place<IssuingCard> {
137        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
138            Ok(Box::new(Builder {
139                out: &mut self.out,
140                builder: IssuingCardBuilder::deser_default(),
141            }))
142        }
143    }
144
145    impl MapBuilder for IssuingCardBuilder {
146        type Out = IssuingCard;
147        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
148            Ok(match k {
149                "brand" => Deserialize::begin(&mut self.brand),
150                "cancellation_reason" => Deserialize::begin(&mut self.cancellation_reason),
151                "cardholder" => Deserialize::begin(&mut self.cardholder),
152                "created" => Deserialize::begin(&mut self.created),
153                "currency" => Deserialize::begin(&mut self.currency),
154                "cvc" => Deserialize::begin(&mut self.cvc),
155                "exp_month" => Deserialize::begin(&mut self.exp_month),
156                "exp_year" => Deserialize::begin(&mut self.exp_year),
157                "financial_account" => Deserialize::begin(&mut self.financial_account),
158                "id" => Deserialize::begin(&mut self.id),
159                "last4" => Deserialize::begin(&mut self.last4),
160                "latest_fraud_warning" => Deserialize::begin(&mut self.latest_fraud_warning),
161                "lifecycle_controls" => Deserialize::begin(&mut self.lifecycle_controls),
162                "livemode" => Deserialize::begin(&mut self.livemode),
163                "metadata" => Deserialize::begin(&mut self.metadata),
164                "number" => Deserialize::begin(&mut self.number),
165                "personalization_design" => Deserialize::begin(&mut self.personalization_design),
166                "replaced_by" => Deserialize::begin(&mut self.replaced_by),
167                "replacement_for" => Deserialize::begin(&mut self.replacement_for),
168                "replacement_reason" => Deserialize::begin(&mut self.replacement_reason),
169                "second_line" => Deserialize::begin(&mut self.second_line),
170                "shipping" => Deserialize::begin(&mut self.shipping),
171                "spending_controls" => Deserialize::begin(&mut self.spending_controls),
172                "status" => Deserialize::begin(&mut self.status),
173                "type" => Deserialize::begin(&mut self.type_),
174                "wallets" => Deserialize::begin(&mut self.wallets),
175                _ => <dyn Visitor>::ignore(),
176            })
177        }
178
179        fn deser_default() -> Self {
180            Self {
181                brand: None,
182                cancellation_reason: Some(None),
183                cardholder: None,
184                created: None,
185                currency: None,
186                cvc: Some(None),
187                exp_month: None,
188                exp_year: None,
189                financial_account: Some(None),
190                id: None,
191                last4: None,
192                latest_fraud_warning: Some(None),
193                lifecycle_controls: Some(None),
194                livemode: None,
195                metadata: None,
196                number: Some(None),
197                personalization_design: Some(None),
198                replaced_by: Some(None),
199                replacement_for: Some(None),
200                replacement_reason: Some(None),
201                second_line: Some(None),
202                shipping: Some(None),
203                spending_controls: None,
204                status: None,
205                type_: None,
206                wallets: Some(None),
207            }
208        }
209
210        fn take_out(&mut self) -> Option<Self::Out> {
211            let (
212                Some(brand),
213                Some(cancellation_reason),
214                Some(cardholder),
215                Some(created),
216                Some(currency),
217                Some(cvc),
218                Some(exp_month),
219                Some(exp_year),
220                Some(financial_account),
221                Some(id),
222                Some(last4),
223                Some(latest_fraud_warning),
224                Some(lifecycle_controls),
225                Some(livemode),
226                Some(metadata),
227                Some(number),
228                Some(personalization_design),
229                Some(replaced_by),
230                Some(replacement_for),
231                Some(replacement_reason),
232                Some(second_line),
233                Some(shipping),
234                Some(spending_controls),
235                Some(status),
236                Some(type_),
237                Some(wallets),
238            ) = (
239                self.brand.take(),
240                self.cancellation_reason.take(),
241                self.cardholder.take(),
242                self.created,
243                self.currency.take(),
244                self.cvc.take(),
245                self.exp_month,
246                self.exp_year,
247                self.financial_account.take(),
248                self.id.take(),
249                self.last4.take(),
250                self.latest_fraud_warning.take(),
251                self.lifecycle_controls,
252                self.livemode,
253                self.metadata.take(),
254                self.number.take(),
255                self.personalization_design.take(),
256                self.replaced_by.take(),
257                self.replacement_for.take(),
258                self.replacement_reason.take(),
259                self.second_line.take(),
260                self.shipping.take(),
261                self.spending_controls.take(),
262                self.status.take(),
263                self.type_.take(),
264                self.wallets.take(),
265            )
266            else {
267                return None;
268            };
269            Some(Self::Out {
270                brand,
271                cancellation_reason,
272                cardholder,
273                created,
274                currency,
275                cvc,
276                exp_month,
277                exp_year,
278                financial_account,
279                id,
280                last4,
281                latest_fraud_warning,
282                lifecycle_controls,
283                livemode,
284                metadata,
285                number,
286                personalization_design,
287                replaced_by,
288                replacement_for,
289                replacement_reason,
290                second_line,
291                shipping,
292                spending_controls,
293                status,
294                type_,
295                wallets,
296            })
297        }
298    }
299
300    impl Map for Builder<'_> {
301        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
302            self.builder.key(k)
303        }
304
305        fn finish(&mut self) -> Result<()> {
306            *self.out = self.builder.take_out();
307            Ok(())
308        }
309    }
310
311    impl ObjectDeser for IssuingCard {
312        type Builder = IssuingCardBuilder;
313    }
314
315    impl FromValueOpt for IssuingCard {
316        fn from_value(v: Value) -> Option<Self> {
317            let Value::Object(obj) = v else {
318                return None;
319            };
320            let mut b = IssuingCardBuilder::deser_default();
321            for (k, v) in obj {
322                match k.as_str() {
323                    "brand" => b.brand = FromValueOpt::from_value(v),
324                    "cancellation_reason" => b.cancellation_reason = FromValueOpt::from_value(v),
325                    "cardholder" => b.cardholder = FromValueOpt::from_value(v),
326                    "created" => b.created = FromValueOpt::from_value(v),
327                    "currency" => b.currency = FromValueOpt::from_value(v),
328                    "cvc" => b.cvc = FromValueOpt::from_value(v),
329                    "exp_month" => b.exp_month = FromValueOpt::from_value(v),
330                    "exp_year" => b.exp_year = FromValueOpt::from_value(v),
331                    "financial_account" => b.financial_account = FromValueOpt::from_value(v),
332                    "id" => b.id = FromValueOpt::from_value(v),
333                    "last4" => b.last4 = FromValueOpt::from_value(v),
334                    "latest_fraud_warning" => b.latest_fraud_warning = FromValueOpt::from_value(v),
335                    "lifecycle_controls" => b.lifecycle_controls = FromValueOpt::from_value(v),
336                    "livemode" => b.livemode = FromValueOpt::from_value(v),
337                    "metadata" => b.metadata = FromValueOpt::from_value(v),
338                    "number" => b.number = FromValueOpt::from_value(v),
339                    "personalization_design" => {
340                        b.personalization_design = FromValueOpt::from_value(v)
341                    }
342                    "replaced_by" => b.replaced_by = FromValueOpt::from_value(v),
343                    "replacement_for" => b.replacement_for = FromValueOpt::from_value(v),
344                    "replacement_reason" => b.replacement_reason = FromValueOpt::from_value(v),
345                    "second_line" => b.second_line = FromValueOpt::from_value(v),
346                    "shipping" => b.shipping = FromValueOpt::from_value(v),
347                    "spending_controls" => b.spending_controls = FromValueOpt::from_value(v),
348                    "status" => b.status = FromValueOpt::from_value(v),
349                    "type" => b.type_ = FromValueOpt::from_value(v),
350                    "wallets" => b.wallets = FromValueOpt::from_value(v),
351                    _ => {}
352                }
353            }
354            b.take_out()
355        }
356    }
357};
358#[cfg(feature = "serialize")]
359impl serde::Serialize for IssuingCard {
360    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
361        use serde::ser::SerializeStruct;
362        let mut s = s.serialize_struct("IssuingCard", 27)?;
363        s.serialize_field("brand", &self.brand)?;
364        s.serialize_field("cancellation_reason", &self.cancellation_reason)?;
365        s.serialize_field("cardholder", &self.cardholder)?;
366        s.serialize_field("created", &self.created)?;
367        s.serialize_field("currency", &self.currency)?;
368        s.serialize_field("cvc", &self.cvc)?;
369        s.serialize_field("exp_month", &self.exp_month)?;
370        s.serialize_field("exp_year", &self.exp_year)?;
371        s.serialize_field("financial_account", &self.financial_account)?;
372        s.serialize_field("id", &self.id)?;
373        s.serialize_field("last4", &self.last4)?;
374        s.serialize_field("latest_fraud_warning", &self.latest_fraud_warning)?;
375        s.serialize_field("lifecycle_controls", &self.lifecycle_controls)?;
376        s.serialize_field("livemode", &self.livemode)?;
377        s.serialize_field("metadata", &self.metadata)?;
378        s.serialize_field("number", &self.number)?;
379        s.serialize_field("personalization_design", &self.personalization_design)?;
380        s.serialize_field("replaced_by", &self.replaced_by)?;
381        s.serialize_field("replacement_for", &self.replacement_for)?;
382        s.serialize_field("replacement_reason", &self.replacement_reason)?;
383        s.serialize_field("second_line", &self.second_line)?;
384        s.serialize_field("shipping", &self.shipping)?;
385        s.serialize_field("spending_controls", &self.spending_controls)?;
386        s.serialize_field("status", &self.status)?;
387        s.serialize_field("type", &self.type_)?;
388        s.serialize_field("wallets", &self.wallets)?;
389
390        s.serialize_field("object", "issuing.card")?;
391        s.end()
392    }
393}
394/// The reason why the card was canceled.
395#[derive(Clone, Eq, PartialEq)]
396#[non_exhaustive]
397pub enum IssuingCardCancellationReason {
398    DesignRejected,
399    FulfillmentError,
400    Lost,
401    Stolen,
402    /// An unrecognized value from Stripe. Should not be used as a request parameter.
403    Unknown(String),
404}
405impl IssuingCardCancellationReason {
406    pub fn as_str(&self) -> &str {
407        use IssuingCardCancellationReason::*;
408        match self {
409            DesignRejected => "design_rejected",
410            FulfillmentError => "fulfillment_error",
411            Lost => "lost",
412            Stolen => "stolen",
413            Unknown(v) => v,
414        }
415    }
416}
417
418impl std::str::FromStr for IssuingCardCancellationReason {
419    type Err = std::convert::Infallible;
420    fn from_str(s: &str) -> Result<Self, Self::Err> {
421        use IssuingCardCancellationReason::*;
422        match s {
423            "design_rejected" => Ok(DesignRejected),
424            "fulfillment_error" => Ok(FulfillmentError),
425            "lost" => Ok(Lost),
426            "stolen" => Ok(Stolen),
427            v => {
428                tracing::warn!(
429                    "Unknown value '{}' for enum '{}'",
430                    v,
431                    "IssuingCardCancellationReason"
432                );
433                Ok(Unknown(v.to_owned()))
434            }
435        }
436    }
437}
438impl std::fmt::Display for IssuingCardCancellationReason {
439    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
440        f.write_str(self.as_str())
441    }
442}
443
444#[cfg(not(feature = "redact-generated-debug"))]
445impl std::fmt::Debug for IssuingCardCancellationReason {
446    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
447        f.write_str(self.as_str())
448    }
449}
450#[cfg(feature = "redact-generated-debug")]
451impl std::fmt::Debug for IssuingCardCancellationReason {
452    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
453        f.debug_struct(stringify!(IssuingCardCancellationReason)).finish_non_exhaustive()
454    }
455}
456#[cfg(feature = "serialize")]
457impl serde::Serialize for IssuingCardCancellationReason {
458    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
459    where
460        S: serde::Serializer,
461    {
462        serializer.serialize_str(self.as_str())
463    }
464}
465impl miniserde::Deserialize for IssuingCardCancellationReason {
466    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
467        crate::Place::new(out)
468    }
469}
470
471impl miniserde::de::Visitor for crate::Place<IssuingCardCancellationReason> {
472    fn string(&mut self, s: &str) -> miniserde::Result<()> {
473        use std::str::FromStr;
474        self.out = Some(IssuingCardCancellationReason::from_str(s).expect("infallible"));
475        Ok(())
476    }
477}
478
479stripe_types::impl_from_val_with_from_str!(IssuingCardCancellationReason);
480#[cfg(feature = "deserialize")]
481impl<'de> serde::Deserialize<'de> for IssuingCardCancellationReason {
482    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
483        use std::str::FromStr;
484        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
485        Ok(Self::from_str(&s).expect("infallible"))
486    }
487}
488/// The reason why the previous card needed to be replaced.
489#[derive(Clone, Eq, PartialEq)]
490#[non_exhaustive]
491pub enum IssuingCardReplacementReason {
492    Damaged,
493    Expired,
494    FulfillmentError,
495    Lost,
496    Stolen,
497    /// An unrecognized value from Stripe. Should not be used as a request parameter.
498    Unknown(String),
499}
500impl IssuingCardReplacementReason {
501    pub fn as_str(&self) -> &str {
502        use IssuingCardReplacementReason::*;
503        match self {
504            Damaged => "damaged",
505            Expired => "expired",
506            FulfillmentError => "fulfillment_error",
507            Lost => "lost",
508            Stolen => "stolen",
509            Unknown(v) => v,
510        }
511    }
512}
513
514impl std::str::FromStr for IssuingCardReplacementReason {
515    type Err = std::convert::Infallible;
516    fn from_str(s: &str) -> Result<Self, Self::Err> {
517        use IssuingCardReplacementReason::*;
518        match s {
519            "damaged" => Ok(Damaged),
520            "expired" => Ok(Expired),
521            "fulfillment_error" => Ok(FulfillmentError),
522            "lost" => Ok(Lost),
523            "stolen" => Ok(Stolen),
524            v => {
525                tracing::warn!(
526                    "Unknown value '{}' for enum '{}'",
527                    v,
528                    "IssuingCardReplacementReason"
529                );
530                Ok(Unknown(v.to_owned()))
531            }
532        }
533    }
534}
535impl std::fmt::Display for IssuingCardReplacementReason {
536    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
537        f.write_str(self.as_str())
538    }
539}
540
541#[cfg(not(feature = "redact-generated-debug"))]
542impl std::fmt::Debug for IssuingCardReplacementReason {
543    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
544        f.write_str(self.as_str())
545    }
546}
547#[cfg(feature = "redact-generated-debug")]
548impl std::fmt::Debug for IssuingCardReplacementReason {
549    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
550        f.debug_struct(stringify!(IssuingCardReplacementReason)).finish_non_exhaustive()
551    }
552}
553#[cfg(feature = "serialize")]
554impl serde::Serialize for IssuingCardReplacementReason {
555    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
556    where
557        S: serde::Serializer,
558    {
559        serializer.serialize_str(self.as_str())
560    }
561}
562impl miniserde::Deserialize for IssuingCardReplacementReason {
563    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
564        crate::Place::new(out)
565    }
566}
567
568impl miniserde::de::Visitor for crate::Place<IssuingCardReplacementReason> {
569    fn string(&mut self, s: &str) -> miniserde::Result<()> {
570        use std::str::FromStr;
571        self.out = Some(IssuingCardReplacementReason::from_str(s).expect("infallible"));
572        Ok(())
573    }
574}
575
576stripe_types::impl_from_val_with_from_str!(IssuingCardReplacementReason);
577#[cfg(feature = "deserialize")]
578impl<'de> serde::Deserialize<'de> for IssuingCardReplacementReason {
579    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
580        use std::str::FromStr;
581        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
582        Ok(Self::from_str(&s).expect("infallible"))
583    }
584}
585impl stripe_types::Object for IssuingCard {
586    type Id = stripe_shared::IssuingCardId;
587    fn id(&self) -> &Self::Id {
588        &self.id
589    }
590
591    fn into_id(self) -> Self::Id {
592        self.id
593    }
594}
595stripe_types::def_id!(IssuingCardId);
596#[derive(Clone, Eq, PartialEq)]
597#[non_exhaustive]
598pub enum IssuingCardStatus {
599    Active,
600    Canceled,
601    Inactive,
602    /// An unrecognized value from Stripe. Should not be used as a request parameter.
603    Unknown(String),
604}
605impl IssuingCardStatus {
606    pub fn as_str(&self) -> &str {
607        use IssuingCardStatus::*;
608        match self {
609            Active => "active",
610            Canceled => "canceled",
611            Inactive => "inactive",
612            Unknown(v) => v,
613        }
614    }
615}
616
617impl std::str::FromStr for IssuingCardStatus {
618    type Err = std::convert::Infallible;
619    fn from_str(s: &str) -> Result<Self, Self::Err> {
620        use IssuingCardStatus::*;
621        match s {
622            "active" => Ok(Active),
623            "canceled" => Ok(Canceled),
624            "inactive" => Ok(Inactive),
625            v => {
626                tracing::warn!("Unknown value '{}' for enum '{}'", v, "IssuingCardStatus");
627                Ok(Unknown(v.to_owned()))
628            }
629        }
630    }
631}
632impl std::fmt::Display for IssuingCardStatus {
633    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
634        f.write_str(self.as_str())
635    }
636}
637
638#[cfg(not(feature = "redact-generated-debug"))]
639impl std::fmt::Debug for IssuingCardStatus {
640    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
641        f.write_str(self.as_str())
642    }
643}
644#[cfg(feature = "redact-generated-debug")]
645impl std::fmt::Debug for IssuingCardStatus {
646    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
647        f.debug_struct(stringify!(IssuingCardStatus)).finish_non_exhaustive()
648    }
649}
650impl serde::Serialize for IssuingCardStatus {
651    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
652    where
653        S: serde::Serializer,
654    {
655        serializer.serialize_str(self.as_str())
656    }
657}
658impl miniserde::Deserialize for IssuingCardStatus {
659    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
660        crate::Place::new(out)
661    }
662}
663
664impl miniserde::de::Visitor for crate::Place<IssuingCardStatus> {
665    fn string(&mut self, s: &str) -> miniserde::Result<()> {
666        use std::str::FromStr;
667        self.out = Some(IssuingCardStatus::from_str(s).expect("infallible"));
668        Ok(())
669    }
670}
671
672stripe_types::impl_from_val_with_from_str!(IssuingCardStatus);
673#[cfg(feature = "deserialize")]
674impl<'de> serde::Deserialize<'de> for IssuingCardStatus {
675    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
676        use std::str::FromStr;
677        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
678        Ok(Self::from_str(&s).expect("infallible"))
679    }
680}
681#[derive(Clone, Eq, PartialEq)]
682#[non_exhaustive]
683pub enum IssuingCardType {
684    Physical,
685    Virtual,
686    /// An unrecognized value from Stripe. Should not be used as a request parameter.
687    Unknown(String),
688}
689impl IssuingCardType {
690    pub fn as_str(&self) -> &str {
691        use IssuingCardType::*;
692        match self {
693            Physical => "physical",
694            Virtual => "virtual",
695            Unknown(v) => v,
696        }
697    }
698}
699
700impl std::str::FromStr for IssuingCardType {
701    type Err = std::convert::Infallible;
702    fn from_str(s: &str) -> Result<Self, Self::Err> {
703        use IssuingCardType::*;
704        match s {
705            "physical" => Ok(Physical),
706            "virtual" => Ok(Virtual),
707            v => {
708                tracing::warn!("Unknown value '{}' for enum '{}'", v, "IssuingCardType");
709                Ok(Unknown(v.to_owned()))
710            }
711        }
712    }
713}
714impl std::fmt::Display for IssuingCardType {
715    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
716        f.write_str(self.as_str())
717    }
718}
719
720#[cfg(not(feature = "redact-generated-debug"))]
721impl std::fmt::Debug for IssuingCardType {
722    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
723        f.write_str(self.as_str())
724    }
725}
726#[cfg(feature = "redact-generated-debug")]
727impl std::fmt::Debug for IssuingCardType {
728    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
729        f.debug_struct(stringify!(IssuingCardType)).finish_non_exhaustive()
730    }
731}
732impl serde::Serialize for IssuingCardType {
733    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
734    where
735        S: serde::Serializer,
736    {
737        serializer.serialize_str(self.as_str())
738    }
739}
740impl miniserde::Deserialize for IssuingCardType {
741    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
742        crate::Place::new(out)
743    }
744}
745
746impl miniserde::de::Visitor for crate::Place<IssuingCardType> {
747    fn string(&mut self, s: &str) -> miniserde::Result<()> {
748        use std::str::FromStr;
749        self.out = Some(IssuingCardType::from_str(s).expect("infallible"));
750        Ok(())
751    }
752}
753
754stripe_types::impl_from_val_with_from_str!(IssuingCardType);
755#[cfg(feature = "deserialize")]
756impl<'de> serde::Deserialize<'de> for IssuingCardType {
757    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
758        use std::str::FromStr;
759        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
760        Ok(Self::from_str(&s).expect("infallible"))
761    }
762}