stripe/resources/generated/discount.rs
1// ======================================
2// This file was automatically generated.
3// ======================================
4
5use crate::ids::DiscountId;
6use crate::params::{Expandable, Object, Timestamp};
7use crate::resources::{Coupon, Customer, PromotionCode};
8use serde::{Deserialize, Serialize};
9
10/// The resource representing a Stripe "Discount".
11///
12/// For more details see <https://stripe.com/docs/api/discounts/object>
13#[derive(Clone, Debug, Default, Deserialize, Serialize)]
14pub struct Discount {
15 /// The ID of the discount object.
16 ///
17 /// Discounts cannot be fetched by ID.
18 /// Use `expand[]=discounts` in API calls to expand discount IDs in an array.
19 pub id: DiscountId,
20
21 /// The Checkout session that this coupon is applied to, if it is applied to a particular session in payment mode.
22 ///
23 /// Will not be present for subscription mode.
24 pub checkout_session: Option<String>,
25
26 pub coupon: Coupon,
27
28 /// The ID of the customer associated with this discount.
29 pub customer: Option<Expandable<Customer>>,
30
31 // Always true for a deleted object
32 #[serde(default)]
33 pub deleted: bool,
34
35 /// If the coupon has a duration of `repeating`, the date that this discount will end.
36 ///
37 /// If the coupon has a duration of `once` or `forever`, this attribute will be null.
38 #[serde(skip_serializing_if = "Option::is_none")]
39 pub end: Option<Timestamp>,
40
41 /// The invoice that the discount's coupon was applied to, if it was applied directly to a particular invoice.
42 pub invoice: Option<String>,
43
44 /// The invoice item `id` (or invoice line item `id` for invoice line items of type='subscription') that the discount's coupon was applied to, if it was applied directly to a particular invoice item or invoice line item.
45 pub invoice_item: Option<String>,
46
47 /// The promotion code applied to create this discount.
48 pub promotion_code: Option<Expandable<PromotionCode>>,
49
50 /// Date that the coupon was applied.
51 pub start: Timestamp,
52
53 /// The subscription that this coupon is applied to, if it is applied to a particular subscription.
54 pub subscription: Option<String>,
55}
56
57impl Object for Discount {
58 type Id = DiscountId;
59 fn id(&self) -> Self::Id {
60 self.id.clone()
61 }
62 fn object(&self) -> &'static str {
63 "discount"
64 }
65}