openconfiguration/
commercial.rs

1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4
5use crate::impl_visitable_noop;
6
7#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
8#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
9#[cfg_attr(feature = "schema", schemars(deny_unknown_fields))]
10#[serde(rename_all = "camelCase")]
11pub struct Commercial {
12    /// The instance id of the product in the configurator/basket.
13    pub id: String,
14
15    /// The instance id of an associated master product, e.g. a set.
16    pub master_id: Option<String>,
17
18    /// The (basic) article code.
19    pub article: Option<String>,
20
21    /// Additional article code that describes the specific variant.
22    pub variant: Option<String>,
23
24    /// The native id.
25    ///
26    /// In case of IDM, this is <series/>|<product/>.
27    ///
28    /// In case of XcalibuR, this is <model_source_id/>@@<product_source_id/>
29    pub native_id: Option<String>,
30
31    /// Short (one-line), localized article text.
32    #[serde(
33        deserialize_with = "crate::utils::deserialize_optional_map_without_null_values",
34        default
35    )]
36    pub short_text: Option<HashMap<String, String>>,
37
38    /// Long, localized article text. Key is ISO 639-1 language code.
39    #[serde(
40        deserialize_with = "crate::utils::deserialize_optional_map_without_null_values",
41        default
42    )]
43    pub long_text: Option<HashMap<String, Vec<String>>>,
44
45    /// Long, localized article text that describes the variant. Used as an addition
46    /// to the long text, not as replacement. Key is ISO 639-1 language code.
47    #[serde(
48        deserialize_with = "crate::utils::deserialize_optional_map_without_null_values",
49        default
50    )]
51    pub variant_text: Option<HashMap<String, Vec<String>>>,
52
53    ///  The price unit, for all prices of this article. Possible values:
54    ///  "EUR_Ct" - Euro Cent
55    ///  "USD_Ct" - USD Cent
56    ///  "CHF_Rp" - CHF Rappen
57    pub price_unit: Option<String>,
58
59    ///  The article's sales price, according to the price unit.  
60    pub sales_price: Option<i64>,
61
62    ///  The article's purchase price, according to the price unit.  
63    pub purchase_price: Option<i64>,
64
65    ///
66    /// The properties of the article.
67    ///
68    #[serde(default)]
69    pub properties: Vec<Property>,
70}
71
72impl_visitable_noop!(Commercial);
73
74#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
75#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
76#[cfg_attr(feature = "schema", schemars(deny_unknown_fields))]
77#[serde(rename_all = "camelCase")]
78pub struct Property {
79    /// The unique id of the property.
80    pub property_id: String,
81
82    /// Localized property text. Key is ISO 639-1 language code.
83    #[serde(deserialize_with = "crate::utils::deserialize_optional_map_without_null_values")]
84    pub property_text: Option<HashMap<String, String>>,
85
86    /// The optional id of the property's current value.
87    pub value_id: Option<String>,
88
89    /// The localized text of the value. Needed if valueId cannot be
90    /// resolved in Values.
91    #[serde(
92        deserialize_with = "crate::utils::deserialize_optional_map_without_null_values",
93        default
94    )]
95    pub value_text: Option<HashMap<String, String>>,
96
97    /// The position of the property in the product's property editor.
98    pub position: i32,
99
100    /// The values of the property.
101    pub values: Option<Vec<Value>>,
102}
103
104#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
105#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
106#[cfg_attr(feature = "schema", schemars(deny_unknown_fields))]
107#[serde(rename_all = "camelCase")]
108/// Value of properties
109pub struct Value {
110    /// The unique id of the property value.
111    pub value_id: String,
112
113    /// Localized value text. Key is ISO 639-1 language code.
114    #[serde(
115        deserialize_with = "crate::utils::deserialize_optional_map_without_null_values",
116        default
117    )]
118    pub value_text: Option<HashMap<String, String>>,
119
120    /// The position of the value in the property's selection list.
121    pub position: i32,
122
123    /// The sub values of the value.
124    pub values: Vec<Value>,
125}