1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
// ======================================
// This file was automatically generated.
// ======================================

use crate::ids::IssuingCardId;
use crate::params::{Expandable, Metadata, Object, Timestamp};
use crate::resources::{
    Address, CardBrand, Currency, IssuingCardholder, MerchantCategory, SpendingLimit,
};
use serde_derive::{Deserialize, Serialize};

/// The resource representing a Stripe "IssuingCard".
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct IssuingCard {
    /// Unique identifier for the object.
    pub id: IssuingCardId,

    pub authorization_controls: IssuingCardAuthorizationControls,

    /// The brand of the card.
    pub brand: CardBrand,

    /// The [Cardholder](https://stripe.com/docs/api#issuing_cardholder_object) object to which the card belongs.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cardholder: Option<IssuingCardholder>,

    /// Time at which the object was created.
    ///
    /// Measured in seconds since the Unix epoch.
    pub created: Timestamp,

    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
    ///
    /// Must be a [supported currency](https://stripe.com/docs/currencies).
    pub currency: Currency,

    /// The expiration month of the card.
    pub exp_month: i64,

    /// The expiration year of the card.
    pub exp_year: i64,

    /// The last 4 digits of the card number.
    pub last4: String,

    /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
    pub livemode: bool,

    /// Set of key-value pairs that you can attach to an object.
    ///
    /// This can be useful for storing additional information about the object in a structured format.
    pub metadata: Metadata,

    /// The name of the cardholder, printed on the card.
    pub name: String,

    /// The card this card replaces, if any.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub replacement_for: Option<Expandable<IssuingCard>>,

    /// Why the card that this card replaces (if any) needed to be replaced.
    ///
    /// One of `damage`, `expiration`, `loss`, or `theft`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub replacement_reason: Option<IssuingCardReplacementReason>,

    /// Where and how the card will be shipped.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub shipping: Option<IssuingCardShipping>,

    /// One of `active`, `inactive`, `canceled`, `lost`, `stolen`, or `pending`.
    pub status: IssuingCardStatus,

    /// One of `virtual` or `physical`.
    #[serde(rename = "type")]
    pub type_: IssuingCardType,
}

impl Object for IssuingCard {
    type Id = IssuingCardId;
    fn id(&self) -> Self::Id {
        self.id.clone()
    }
    fn object(&self) -> &'static str {
        "issuing.card"
    }
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct IssuingCardAuthorizationControls {
    /// Array of strings containing [categories](https://stripe.com/docs/api#issuing_authorization_object-merchant_data-category) of authorizations permitted on this card.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub allowed_categories: Option<Vec<MerchantCategory>>,

    /// Array of strings containing [categories](https://stripe.com/docs/api#issuing_authorization_object-merchant_data-category) of authorizations to always decline on this card.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub blocked_categories: Option<Vec<MerchantCategory>>,

    /// The currency of the card.
    ///
    /// See [max_amount](https://stripe.com/docs/api#issuing_card_object-authorization_controls-max_amount).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub currency: Option<Currency>,

    /// Maximum amount allowed per authorization on this card, in the currency of the card.
    ///
    /// Authorization amounts in a different currency will be converted to the card's currency when evaluating this control.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_amount: Option<i64>,

    /// Maximum count of approved authorizations on this card.
    ///
    /// Counts all authorizations retroactively.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_approvals: Option<i64>,

    /// Limit the spending with rules based on time intervals and categories.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub spending_limits: Option<Vec<SpendingLimit>>,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct IssuingCardShipping {
    pub address: Address,

    /// The delivery service that shipped a physical product, such as Fedex, UPS, USPS, etc.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub carrier: Option<String>,

    /// A unix timestamp representing a best estimate of when the card will be delivered.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub eta: Option<Timestamp>,

    /// Recipient name.
    pub name: String,

    /// The delivery status of the card.
    ///
    /// One of `pending`, `shipped`, `delivered`, `returned`, `failure`, or `canceled`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<IssuingCardShippingStatus>,

    /// A tracking number for a card shipment.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tracking_number: Option<String>,

    /// A link to the shipping carrier's site where you can view detailed information about a card shipment.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tracking_url: Option<String>,

    /// One of `bulk` or `individual`.
    ///
    /// Bulk shipments will be grouped and mailed together, while individual ones will not.
    #[serde(rename = "type")]
    pub type_: IssuingCardShippingType,
}

/// An enum representing the possible values of an `IssuingCard`'s `replacement_reason` field.
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum IssuingCardReplacementReason {
    Damage,
    Expiration,
    Loss,
    Theft,
}

impl IssuingCardReplacementReason {
    pub fn as_str(&self) -> &'static str {
        match self {
            IssuingCardReplacementReason::Damage => "damage",
            IssuingCardReplacementReason::Expiration => "expiration",
            IssuingCardReplacementReason::Loss => "loss",
            IssuingCardReplacementReason::Theft => "theft",
        }
    }
}

impl AsRef<str> for IssuingCardReplacementReason {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl std::fmt::Display for IssuingCardReplacementReason {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        self.as_str().fmt(f)
    }
}

/// An enum representing the possible values of an `IssuingCardShipping`'s `status` field.
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum IssuingCardShippingStatus {
    Canceled,
    Delivered,
    Failure,
    Pending,
    Returned,
    Shipped,
}

impl IssuingCardShippingStatus {
    pub fn as_str(&self) -> &'static str {
        match self {
            IssuingCardShippingStatus::Canceled => "canceled",
            IssuingCardShippingStatus::Delivered => "delivered",
            IssuingCardShippingStatus::Failure => "failure",
            IssuingCardShippingStatus::Pending => "pending",
            IssuingCardShippingStatus::Returned => "returned",
            IssuingCardShippingStatus::Shipped => "shipped",
        }
    }
}

impl AsRef<str> for IssuingCardShippingStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl std::fmt::Display for IssuingCardShippingStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        self.as_str().fmt(f)
    }
}

/// An enum representing the possible values of an `IssuingCardShipping`'s `type` field.
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum IssuingCardShippingType {
    Bulk,
    Individual,
}

impl IssuingCardShippingType {
    pub fn as_str(&self) -> &'static str {
        match self {
            IssuingCardShippingType::Bulk => "bulk",
            IssuingCardShippingType::Individual => "individual",
        }
    }
}

impl AsRef<str> for IssuingCardShippingType {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl std::fmt::Display for IssuingCardShippingType {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        self.as_str().fmt(f)
    }
}

/// An enum representing the possible values of an `IssuingCard`'s `status` field.
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum IssuingCardStatus {
    Active,
    Canceled,
    Inactive,
    Lost,
    Pending,
    Stolen,
}

impl IssuingCardStatus {
    pub fn as_str(&self) -> &'static str {
        match self {
            IssuingCardStatus::Active => "active",
            IssuingCardStatus::Canceled => "canceled",
            IssuingCardStatus::Inactive => "inactive",
            IssuingCardStatus::Lost => "lost",
            IssuingCardStatus::Pending => "pending",
            IssuingCardStatus::Stolen => "stolen",
        }
    }
}

impl AsRef<str> for IssuingCardStatus {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl std::fmt::Display for IssuingCardStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        self.as_str().fmt(f)
    }
}

/// An enum representing the possible values of an `IssuingCard`'s `type` field.
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum IssuingCardType {
    Physical,
    Virtual,
}

impl IssuingCardType {
    pub fn as_str(&self) -> &'static str {
        match self {
            IssuingCardType::Physical => "physical",
            IssuingCardType::Virtual => "virtual",
        }
    }
}

impl AsRef<str> for IssuingCardType {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl std::fmt::Display for IssuingCardType {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        self.as_str().fmt(f)
    }
}