square_api_client/models/subscription.rs
1//! Model struct for Subscription type
2
3use serde::{Deserialize, Serialize};
4
5use super::{
6 enums::{SubscriptionStatus, Timezone},
7 DateTime, Money, SubscriptionAction, SubscriptionSource,
8};
9
10/// Represents a subscription to a subscription plan by a subscriber.
11///
12/// For an overview of the `Subscription` type, see [Subscription
13/// object](https://developer.squareup.com/docs/subscriptions-api/overview#subscription-object-overview).
14#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
15pub struct Subscription {
16 /// **Read only** The Square-assigned ID of the subscription.
17 ///
18 /// Max Length: 255
19 pub id: Option<String>,
20 /// **Read only** The ID of the location associated with the subscription.
21 pub location_id: Option<String>,
22 /// **Read only** The ID of the subscribed-to [subscription plan](CatalogSubscriptionPlan).
23 pub plan_id: Option<String>,
24 /// **Read only** The ID of the subscribing [customer](Customer) profile.
25 pub customer_id: Option<String>,
26 /// **Read only** The `YYYY-MM-DD`-formatted date (for example, 2013-01-15) to start the
27 /// subscription.
28 pub start_date: Option<String>,
29 /// The `YYYY-MM-DD`-formatted date (for example, 2013-01-15) to cancel the subscription, when
30 /// the subscription status changes to `CANCELED` and the subscription billing stops.
31 ///
32 /// If this field is not set, the subscription ends according its subscription plan.
33 ///
34 /// This field cannot be updated, other than being cleared.
35 pub canceled_date: Option<String>,
36 /// **Read only** The `YYYY-MM-DD-formatted` date up to when the subscriber is invoiced for the
37 /// subscription.
38 ///
39 /// After the invoice is sent for a given billing period, this date will be the last day of the
40 /// billing period. For example, suppose for the month of May a subscriber gets an invoice (or
41 /// charged the card) on May 1. For the monthly billing scenario, this date is then set to May
42 /// 31.
43 pub charged_through_date: Option<String>,
44 /// **Read only** The current status of the subscription.
45 pub status: Option<SubscriptionStatus>,
46 /// The tax amount applied when billing the subscription. The percentage is expressed in decimal
47 /// form, using a `'.'` as the decimal separator and without a `'%'` sign. For example, a value
48 /// of `7.5` corresponds to 7.5%.
49 pub tax_percentage: Option<String>,
50 /// **Read only** The IDs of the [invoices](Invoice) created for the subscription, listed in
51 /// order when the invoices were created (newest invoices appear first).
52 pub invoice_ids: Option<Vec<String>>,
53 /// A custom price to apply for the subscription. If specified, it overrides the price
54 /// configured by the subscription plan.
55 pub price_override_money: Option<Money>,
56 /// The version of the object. When updating an object, the version supplied must match the
57 /// version in the database, otherwise the write will be rejected as conflicting.
58 pub version: Option<i64>,
59 /// Read only The timestamp when the subscription was created, in RFC 3339 format.
60 pub create_at: Option<DateTime>,
61 /// The ID of the [subscriber's card](Customer) used to charge for the subscription.
62 pub card_id: Option<String>,
63 /// **Read only** Timezone that will be used in date calculations for the subscription. Defaults
64 /// to the timezone of the location based on `location_id`. Format: the IANA Timezone Database
65 /// identifier for the location timezone (for example, `America/Los_Angeles`).
66 pub timezone: Option<Timezone>,
67 /// The origination details of the subscription.
68 pub source: Option<SubscriptionSource>,
69 /// The list of scheduled actions on this subscription. It is set only in the response from
70 /// [RetrieveSubscription](https://developer.squareup.com/reference/square/subscriptions-api/retrieve-subscription)
71 /// with the query parameter of `include=actions` or from
72 /// [SearchSubscriptions](https://developer.squareup.com/reference/square/subscriptions-api/search-subscriptions)
73 /// with the input parameter of `include:["actions"]`.
74 pub actions: Option<Vec<SubscriptionAction>>,
75}