wave_api/inputs/
product.rs1use rust_decimal::Decimal;
2use serde::Serialize;
3
4#[derive(Debug, Clone, Serialize)]
6#[serde(rename_all = "camelCase")]
7pub struct ProductCreateInput {
8 pub business_id: String,
9 pub name: String,
10 pub unit_price: Decimal,
11 #[serde(skip_serializing_if = "Option::is_none")]
12 pub description: Option<String>,
13 #[serde(skip_serializing_if = "Option::is_none")]
14 pub default_sales_tax_ids: Option<Vec<String>>,
15 #[serde(skip_serializing_if = "Option::is_none")]
16 pub income_account_id: Option<String>,
17 #[serde(skip_serializing_if = "Option::is_none")]
18 pub expense_account_id: Option<String>,
19}
20
21impl ProductCreateInput {
22 pub fn new(
23 business_id: impl Into<String>,
24 name: impl Into<String>,
25 unit_price: Decimal,
26 ) -> Self {
27 Self {
28 business_id: business_id.into(),
29 name: name.into(),
30 unit_price,
31 description: None,
32 default_sales_tax_ids: None,
33 income_account_id: None,
34 expense_account_id: None,
35 }
36 }
37
38 pub fn description(mut self, v: impl Into<String>) -> Self {
39 self.description = Some(v.into());
40 self
41 }
42 pub fn income_account_id(mut self, v: impl Into<String>) -> Self {
43 self.income_account_id = Some(v.into());
44 self
45 }
46 pub fn expense_account_id(mut self, v: impl Into<String>) -> Self {
47 self.expense_account_id = Some(v.into());
48 self
49 }
50}
51
52#[derive(Debug, Clone, Serialize)]
54#[serde(rename_all = "camelCase")]
55pub struct ProductPatchInput {
56 pub id: String,
57 #[serde(skip_serializing_if = "Option::is_none")]
58 pub name: Option<String>,
59 #[serde(skip_serializing_if = "Option::is_none")]
60 pub description: Option<String>,
61 #[serde(skip_serializing_if = "Option::is_none")]
62 pub unit_price: Option<Decimal>,
63 #[serde(skip_serializing_if = "Option::is_none")]
64 pub default_sales_tax_ids: Option<Vec<String>>,
65 #[serde(skip_serializing_if = "Option::is_none")]
66 pub income_account_id: Option<String>,
67 #[serde(skip_serializing_if = "Option::is_none")]
68 pub expense_account_id: Option<String>,
69}
70
71impl ProductPatchInput {
72 pub fn new(id: impl Into<String>) -> Self {
73 Self {
74 id: id.into(),
75 name: None,
76 description: None,
77 unit_price: None,
78 default_sales_tax_ids: None,
79 income_account_id: None,
80 expense_account_id: None,
81 }
82 }
83
84 pub fn name(mut self, v: impl Into<String>) -> Self {
85 self.name = Some(v.into());
86 self
87 }
88 pub fn unit_price(mut self, v: Decimal) -> Self {
89 self.unit_price = Some(v);
90 self
91 }
92}
93
94#[derive(Debug, Clone, Serialize)]
96#[serde(rename_all = "camelCase")]
97pub struct ProductArchiveInput {
98 pub id: String,
99}
100
101impl ProductArchiveInput {
102 pub fn new(id: impl Into<String>) -> Self {
103 Self { id: id.into() }
104 }
105}