pipedrive_rs/models/
add_recurring_subscription_request.rs

1/*
2 * Pipedrive API v1
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 1.0.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12
13
14#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
15pub struct AddRecurringSubscriptionRequest {
16    /// The ID of the deal this recurring subscription is associated with
17    #[serde(rename = "deal_id")]
18    pub deal_id: i32,
19    /// The currency of the recurring subscription. Accepts a 3-character currency code.
20    #[serde(rename = "currency")]
21    pub currency: String,
22    /// The description of the recurring subscription
23    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
24    pub description: Option<String>,
25    /// The interval between payments
26    #[serde(rename = "cadence_type")]
27    pub cadence_type: CadenceType,
28    /// Shows how many payments the subscription has. Note that one field must be set: `cycles_count` or `infinite`. If `cycles_count` is set, then `cycle_amount` and `start_date` are also required.
29    #[serde(rename = "cycles_count", skip_serializing_if = "Option::is_none")]
30    pub cycles_count: Option<i32>,
31    /// The amount of each payment
32    #[serde(rename = "cycle_amount")]
33    pub cycle_amount: i32,
34    /// The start date of the recurring subscription. Format: YYYY-MM-DD
35    #[serde(rename = "start_date")]
36    pub start_date: String,
37    /// This indicates that the recurring subscription will last until it's manually canceled or deleted. Note that only one field must be set: `cycles_count` or `infinite`.
38    #[serde(rename = "infinite", skip_serializing_if = "Option::is_none")]
39    pub infinite: Option<bool>,
40    /// Array of additional payments. It requires a minimum structure as follows: [{ amount:SUM, description:DESCRIPTION, due_at:PAYMENT_DATE }]. Replace SUM with a payment amount, DESCRIPTION with an explanation string, PAYMENT_DATE with a date (format YYYY-MM-DD).
41    #[serde(rename = "payments", skip_serializing_if = "Option::is_none")]
42    pub payments: Option<Vec<serde_json::Value>>,
43    /// Indicates that the deal value must be set to recurring subscription's MRR value
44    #[serde(rename = "update_deal_value", skip_serializing_if = "Option::is_none")]
45    pub update_deal_value: Option<bool>,
46}
47
48impl AddRecurringSubscriptionRequest {
49    pub fn new(deal_id: i32, currency: String, cadence_type: CadenceType, cycle_amount: i32, start_date: String) -> AddRecurringSubscriptionRequest {
50        AddRecurringSubscriptionRequest {
51            deal_id,
52            currency,
53            description: None,
54            cadence_type,
55            cycles_count: None,
56            cycle_amount,
57            start_date,
58            infinite: None,
59            payments: None,
60            update_deal_value: None,
61        }
62    }
63}
64
65/// The interval between payments
66#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
67pub enum CadenceType {
68    #[serde(rename = "weekly")]
69    Weekly,
70    #[serde(rename = "monthly")]
71    Monthly,
72    #[serde(rename = "quarterly")]
73    Quarterly,
74    #[serde(rename = "yearly")]
75    Yearly,
76}
77
78impl Default for CadenceType {
79    fn default() -> CadenceType {
80        Self::Weekly
81    }
82}
83