1use serde::Deserialize;
2use serde_json::Value;
3
4#[derive(Debug, Default, Clone)]
7pub struct OffersParams {
8 pub page: i32,
9 pub brand: Option<String>,
10 pub model: Option<String>,
11 pub configuration: Option<String>,
12 pub complectation: Option<String>,
13 pub transmission: Option<String>,
14 pub color: Option<String>,
15 pub body_type: Option<String>,
16 pub engine_type: Option<String>,
17 pub year_from: Option<i32>,
18 pub year_to: Option<i32>,
19 pub mileage_from: Option<i32>,
20 pub mileage_to: Option<i32>,
21 pub price_from: Option<i32>,
22 pub price_to: Option<i32>,
23}
24
25impl OffersParams {
26 pub(crate) fn to_query_pairs(&self) -> Vec<(String, String)> {
29 let mut pairs = vec![("page".to_string(), self.page.to_string())];
30
31 if let Some(ref v) = self.brand { pairs.push(("brand".into(), v.clone())); }
32 if let Some(ref v) = self.model { pairs.push(("model".into(), v.clone())); }
33 if let Some(ref v) = self.configuration { pairs.push(("configuration".into(), v.clone())); }
34 if let Some(ref v) = self.complectation { pairs.push(("complectation".into(), v.clone())); }
35 if let Some(ref v) = self.transmission { pairs.push(("transmission".into(), v.clone())); }
36 if let Some(ref v) = self.color { pairs.push(("color".into(), v.clone())); }
37 if let Some(ref v) = self.body_type { pairs.push(("body_type".into(), v.clone())); }
38 if let Some(ref v) = self.engine_type { pairs.push(("engine_type".into(), v.clone())); }
39 if let Some(v) = self.year_from { pairs.push(("year_from".into(), v.to_string())); }
40 if let Some(v) = self.year_to { pairs.push(("year_to".into(), v.to_string())); }
41 if let Some(v) = self.mileage_from { pairs.push(("mileage_from".into(), v.to_string())); }
42 if let Some(v) = self.mileage_to { pairs.push(("mileage_to".into(), v.to_string())); }
43 if let Some(v) = self.price_from { pairs.push(("price_from".into(), v.to_string())); }
44 if let Some(v) = self.price_to { pairs.push(("price_to".into(), v.to_string())); }
45
46 pairs
47 }
48}
49
50#[derive(Debug, Deserialize)]
52pub struct OffersResponse {
53 pub result: Vec<OfferItem>,
54 pub meta: Meta,
55}
56
57#[derive(Debug, Deserialize)]
59pub struct ChangesResponse {
60 pub result: Vec<ChangeItem>,
61 pub meta: ChangesMeta,
62}
63
64#[derive(Debug, Deserialize)]
66pub struct Meta {
67 pub page: i32,
68 pub next_page: i32,
69 pub limit: i32,
70}
71
72#[derive(Debug, Deserialize)]
74pub struct ChangesMeta {
75 pub cur_change_id: i64,
76 pub next_change_id: i64,
77 pub limit: i32,
78}
79
80#[derive(Debug, Deserialize)]
83pub struct OfferItem {
84 pub id: i64,
85 pub inner_id: String,
86 pub change_type: String,
87 pub created_at: String,
88 pub data: Value,
89}
90
91#[derive(Debug, Deserialize)]
94pub struct ChangeItem {
95 pub id: i64,
96 pub inner_id: String,
97 pub change_type: String,
98 pub created_at: String,
99 pub data: Value,
100}
101
102#[derive(Debug, Deserialize)]
106pub struct OfferData {
107 pub inner_id: String,
108 pub url: String,
109 pub mark: String,
110 pub model: String,
111 pub generation: String,
112 pub configuration: String,
113 pub complectation: String,
114 pub year: String,
115 pub color: String,
116 pub price: String,
117 pub km_age: String,
118 pub engine_type: String,
119 pub transmission_type: String,
120 pub body_type: String,
121 pub address: String,
122 pub seller_type: String,
123 pub is_dealer: bool,
124 pub displacement: String,
125 pub offer_created: String,
126 pub images: Vec<String>,
127}
128
129#[derive(Debug, Deserialize)]
131pub(crate) struct ChangeIdResponse {
132 pub change_id: i64,
133}