pipedrive_rs/models/
add_deal_product_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 AddDealProductRequest {
16    /// The ID of the product to use
17    #[serde(rename = "product_id")]
18    pub product_id: i32,
19    /// The price at which this product will be added to the deal
20    #[serde(rename = "item_price")]
21    pub item_price: f32,
22    /// Quantity – e.g. how many items of this product will be added to the deal
23    #[serde(rename = "quantity")]
24    pub quantity: i32,
25    /// The value of the discount. The `discount_type` field can be used to specify whether the value is an amount or a percentage.
26    #[serde(rename = "discount", skip_serializing_if = "Option::is_none")]
27    pub discount: Option<f32>,
28    /// The type of the discount's value.
29    #[serde(rename = "discount_type", skip_serializing_if = "Option::is_none")]
30    pub discount_type: Option<DiscountType>,
31    /// The duration of the product. If omitted, will be set to 1.
32    #[serde(rename = "duration", skip_serializing_if = "Option::is_none")]
33    pub duration: Option<f32>,
34    #[serde(rename = "duration_unit", skip_serializing_if = "Option::is_none")]
35    pub duration_unit: Option<DurationUnit>,
36    /// The ID of the product variation to use. When omitted, no variation will be used.
37    #[serde(rename = "product_variation_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
38    pub product_variation_id: Option<Option<i32>>,
39    /// A textual comment associated with this product-deal attachment
40    #[serde(rename = "comments", skip_serializing_if = "Option::is_none")]
41    pub comments: Option<String>,
42    /// The tax percentage
43    #[serde(rename = "tax", skip_serializing_if = "Option::is_none")]
44    pub tax: Option<f32>,
45    /// The tax option to be applied to the products. When using `inclusive`, the tax percentage will already be included in the price. When using `exclusive`, the tax will not be included in the price. When using `none`, no tax will be added. Use the `tax` field for defining the tax percentage amount. By default, the user setting value for tax options will be used. Changing this in one product affects the rest of the products attached to the deal.
46    #[serde(rename = "tax_method", skip_serializing_if = "Option::is_none")]
47    pub tax_method: Option<TaxMethod>,
48    /// Whether the product is enabled for a deal or not. This makes it possible to add products to a deal with a specific price and discount criteria, but keep them disabled, which refrains them from being included in the deal value calculation. When omitted, the product will be marked as enabled by default.
49    #[serde(rename = "enabled_flag", skip_serializing_if = "Option::is_none")]
50    pub enabled_flag: Option<bool>,
51}
52
53impl AddDealProductRequest {
54    pub fn new(product_id: i32, item_price: f32, quantity: i32) -> AddDealProductRequest {
55        AddDealProductRequest {
56            product_id,
57            item_price,
58            quantity,
59            discount: None,
60            discount_type: None,
61            duration: None,
62            duration_unit: None,
63            product_variation_id: None,
64            comments: None,
65            tax: None,
66            tax_method: None,
67            enabled_flag: None,
68        }
69    }
70}
71
72/// The type of the discount's value.
73#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
74pub enum DiscountType {
75    #[serde(rename = "percentage")]
76    Percentage,
77    #[serde(rename = "amount")]
78    Amount,
79}
80
81impl Default for DiscountType {
82    fn default() -> DiscountType {
83        Self::Percentage
84    }
85}
86/// 
87#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
88pub enum DurationUnit {
89    #[serde(rename = "hourly")]
90    Hourly,
91    #[serde(rename = "daily")]
92    Daily,
93    #[serde(rename = "weekly")]
94    Weekly,
95    #[serde(rename = "monthly")]
96    Monthly,
97    #[serde(rename = "yearly")]
98    Yearly,
99}
100
101impl Default for DurationUnit {
102    fn default() -> DurationUnit {
103        Self::Hourly
104    }
105}
106/// The tax option to be applied to the products. When using `inclusive`, the tax percentage will already be included in the price. When using `exclusive`, the tax will not be included in the price. When using `none`, no tax will be added. Use the `tax` field for defining the tax percentage amount. By default, the user setting value for tax options will be used. Changing this in one product affects the rest of the products attached to the deal.
107#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
108pub enum TaxMethod {
109    #[serde(rename = "exclusive")]
110    Exclusive,
111    #[serde(rename = "inclusive")]
112    Inclusive,
113    #[serde(rename = "none")]
114    None,
115}
116
117impl Default for TaxMethod {
118    fn default() -> TaxMethod {
119        Self::Exclusive
120    }
121}
122