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
/*
* Pipedrive API v1
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct AddDealProductRequest {
/// The ID of the product to use
#[serde(rename = "product_id")]
pub product_id: i32,
/// The price at which this product will be added to the deal
#[serde(rename = "item_price")]
pub item_price: f32,
/// Quantity – e.g. how many items of this product will be added to the deal
#[serde(rename = "quantity")]
pub quantity: i32,
/// The value of the discount. The `discount_type` field can be used to specify whether the value is an amount or a percentage.
#[serde(rename = "discount", skip_serializing_if = "Option::is_none")]
pub discount: Option<f32>,
/// The type of the discount's value.
#[serde(rename = "discount_type", skip_serializing_if = "Option::is_none")]
pub discount_type: Option<DiscountType>,
/// The duration of the product. If omitted, will be set to 1.
#[serde(rename = "duration", skip_serializing_if = "Option::is_none")]
pub duration: Option<f32>,
#[serde(rename = "duration_unit", skip_serializing_if = "Option::is_none")]
pub duration_unit: Option<DurationUnit>,
/// The ID of the product variation to use. When omitted, no variation will be used.
#[serde(rename = "product_variation_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub product_variation_id: Option<Option<i32>>,
/// A textual comment associated with this product-deal attachment
#[serde(rename = "comments", skip_serializing_if = "Option::is_none")]
pub comments: Option<String>,
/// The tax percentage
#[serde(rename = "tax", skip_serializing_if = "Option::is_none")]
pub tax: Option<f32>,
/// 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.
#[serde(rename = "tax_method", skip_serializing_if = "Option::is_none")]
pub tax_method: Option<TaxMethod>,
/// 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.
#[serde(rename = "enabled_flag", skip_serializing_if = "Option::is_none")]
pub enabled_flag: Option<bool>,
}
impl AddDealProductRequest {
pub fn new(product_id: i32, item_price: f32, quantity: i32) -> AddDealProductRequest {
AddDealProductRequest {
product_id,
item_price,
quantity,
discount: None,
discount_type: None,
duration: None,
duration_unit: None,
product_variation_id: None,
comments: None,
tax: None,
tax_method: None,
enabled_flag: None,
}
}
}
/// The type of the discount's value.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum DiscountType {
#[serde(rename = "percentage")]
Percentage,
#[serde(rename = "amount")]
Amount,
}
impl Default for DiscountType {
fn default() -> DiscountType {
Self::Percentage
}
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum DurationUnit {
#[serde(rename = "hourly")]
Hourly,
#[serde(rename = "daily")]
Daily,
#[serde(rename = "weekly")]
Weekly,
#[serde(rename = "monthly")]
Monthly,
#[serde(rename = "yearly")]
Yearly,
}
impl Default for DurationUnit {
fn default() -> DurationUnit {
Self::Hourly
}
}
/// 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.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum TaxMethod {
#[serde(rename = "exclusive")]
Exclusive,
#[serde(rename = "inclusive")]
Inclusive,
#[serde(rename = "none")]
None,
}
impl Default for TaxMethod {
fn default() -> TaxMethod {
Self::Exclusive
}
}