stripe_shared/
issuing_card.rs

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