1pub mod enums;
2pub mod ids;
3
4use crate::models::enums::OrderStatus;
5use crate::models::ids::{ChatId, OrderId};
6use std::collections::HashMap;
7
8#[derive(Debug, Clone)]
9pub struct OfferSaveRequest<'a> {
10 pub golden_key: &'a str,
11 pub user_agent: &'a str,
12 pub phpsessid: Option<&'a str>,
13 pub csrf: &'a str,
14 pub offer_id: i64,
15 pub node_id: i64,
16 pub params: &'a OfferEditParams,
17}
18
19#[derive(Debug, Clone, Default)]
20pub struct OfferEditParams {
21 pub quantity: Option<String>,
22 pub quantity2: Option<String>,
23 pub method: Option<String>,
24 pub offer_type: Option<String>,
25 pub server_id: Option<String>,
26 pub desc_ru: Option<String>,
27 pub desc_en: Option<String>,
28 pub payment_msg_ru: Option<String>,
29 pub payment_msg_en: Option<String>,
30 pub summary_ru: Option<String>,
31 pub summary_en: Option<String>,
32 pub game: Option<String>,
33 pub images: Option<String>,
34 pub price: Option<String>,
35 pub deactivate_after_sale: Option<bool>,
36 pub active: Option<bool>,
37 pub location: Option<String>,
38 pub deleted: Option<bool>,
39}
40
41#[derive(Debug, Clone, Default)]
42pub struct OfferFullParams {
43 pub offer_id: i64,
44 pub node_id: i64,
45 pub quantity: Option<String>,
46 pub quantity2: Option<String>,
47 pub method: Option<String>,
48 pub offer_type: Option<String>,
49 pub server_id: Option<String>,
50 pub desc_ru: Option<String>,
51 pub desc_en: Option<String>,
52 pub payment_msg_ru: Option<String>,
53 pub payment_msg_en: Option<String>,
54 pub images: Option<String>,
55 pub price: Option<String>,
56 pub deactivate_after_sale: bool,
57 pub active: bool,
58 pub location: Option<String>,
59 pub custom_fields: Vec<OfferCustomField>,
60}
61
62#[derive(Debug, Clone)]
63pub struct OfferCustomField {
64 pub name: String,
65 pub label: String,
66 pub field_type: OfferFieldType,
67 pub value: String,
68 pub options: Vec<OfferFieldOption>,
69}
70
71#[derive(Debug, Clone)]
72pub struct OfferFieldOption {
73 pub value: String,
74 pub label: String,
75 pub selected: bool,
76}
77
78#[derive(Debug, Clone, PartialEq)]
79pub enum OfferFieldType {
80 Text,
81 Textarea,
82 Select,
83 Checkbox,
84 Hidden,
85 Unknown(String),
86}
87
88impl OfferEditParams {
89 pub fn new() -> Self {
90 Self::default()
91 }
92
93 pub fn with_price(mut self, price: impl Into<String>) -> Self {
94 self.price = Some(price.into());
95 self
96 }
97
98 pub fn with_quantity(mut self, quantity: impl Into<String>) -> Self {
99 self.quantity = Some(quantity.into());
100 self
101 }
102
103 pub fn with_desc_ru(mut self, desc: impl Into<String>) -> Self {
104 self.desc_ru = Some(desc.into());
105 self
106 }
107
108 pub fn with_desc_en(mut self, desc: impl Into<String>) -> Self {
109 self.desc_en = Some(desc.into());
110 self
111 }
112
113 pub fn with_method(mut self, method: impl Into<String>) -> Self {
114 self.method = Some(method.into());
115 self
116 }
117
118 pub fn with_server_id(mut self, server_id: impl Into<String>) -> Self {
119 self.server_id = Some(server_id.into());
120 self
121 }
122
123 pub fn with_deactivate_after_sale(mut self, deactivate: bool) -> Self {
124 self.deactivate_after_sale = Some(deactivate);
125 self
126 }
127
128 pub fn with_active(mut self, active: bool) -> Self {
129 self.active = Some(active);
130 self
131 }
132
133 pub fn with_images(mut self, images: impl Into<String>) -> Self {
134 self.images = Some(images.into());
135 self
136 }
137
138 pub fn with_payment_msg_ru(mut self, msg: impl Into<String>) -> Self {
139 self.payment_msg_ru = Some(msg.into());
140 self
141 }
142
143 pub fn with_payment_msg_en(mut self, msg: impl Into<String>) -> Self {
144 self.payment_msg_en = Some(msg.into());
145 self
146 }
147
148 pub fn with_deleted(mut self, deleted: bool) -> Self {
149 self.deleted = Some(deleted);
150 self
151 }
152
153 pub fn merge(self, other: OfferEditParams) -> Self {
154 Self {
155 quantity: other.quantity.filter(|s| !s.is_empty()).or(self.quantity),
156 quantity2: other.quantity2.filter(|s| !s.is_empty()).or(self.quantity2),
157 method: other.method.filter(|s| !s.is_empty()).or(self.method),
158 offer_type: other
159 .offer_type
160 .filter(|s| !s.is_empty())
161 .or(self.offer_type),
162 server_id: other.server_id.filter(|s| !s.is_empty()).or(self.server_id),
163 desc_ru: other.desc_ru.filter(|s| !s.is_empty()).or(self.desc_ru),
164 desc_en: other.desc_en.filter(|s| !s.is_empty()).or(self.desc_en),
165 payment_msg_ru: other
166 .payment_msg_ru
167 .filter(|s| !s.is_empty())
168 .or(self.payment_msg_ru),
169 payment_msg_en: other
170 .payment_msg_en
171 .filter(|s| !s.is_empty())
172 .or(self.payment_msg_en),
173 summary_ru: other
174 .summary_ru
175 .filter(|s| !s.is_empty())
176 .or(self.summary_ru),
177 summary_en: other
178 .summary_en
179 .filter(|s| !s.is_empty())
180 .or(self.summary_en),
181 game: other.game.filter(|s| !s.is_empty()).or(self.game),
182 images: other.images.filter(|s| !s.is_empty()).or(self.images),
183 price: other.price.filter(|s| !s.is_empty()).or(self.price),
184 deactivate_after_sale: other.deactivate_after_sale.or(self.deactivate_after_sale),
185 active: other.active.or(self.active),
186 location: other.location.filter(|s| !s.is_empty()).or(self.location),
187 deleted: other.deleted.or(self.deleted),
188 }
189 }
190}
191
192#[derive(Debug, Clone)]
193pub struct Offer {
194 pub id: i64,
195 pub node_id: i64,
196 pub description: String,
197 pub price: f64,
198 pub currency: String,
199 pub active: bool,
200}
201
202#[derive(Debug, Clone)]
203pub struct MarketOffer {
204 pub id: i64,
205 pub node_id: i64,
206 pub description: String,
207 pub price: f64,
208 pub currency: String,
209 pub seller_id: i64,
210 pub seller_name: String,
211 pub seller_online: bool,
212 pub seller_rating: Option<f64>,
213 pub seller_reviews: u32,
214 pub is_promo: bool,
215}
216
217#[derive(Debug, Clone)]
218pub struct ChatShortcut {
219 pub id: i64,
220 pub name: String,
221 pub last_message_text: Option<String>,
222 pub node_msg_id: i64,
223 pub user_msg_id: i64,
224 pub unread: bool,
225}
226
227#[derive(Debug, Clone)]
228pub struct Message {
229 pub id: i64,
230 pub chat_id: ChatId,
231 pub chat_name: Option<String>,
232 pub text: Option<String>,
233 pub interlocutor_id: Option<i64>,
234 pub author_id: i64,
235}
236
237#[derive(Debug, Clone)]
238pub struct OrderShortcut {
239 pub id: OrderId,
240 pub description: String,
241 pub price: f64,
242 pub currency: String,
243 pub buyer_username: String,
244 pub buyer_id: i64,
245 pub chat_id: ChatId,
246 pub status: OrderStatus,
247 pub date_text: String,
248 pub subcategory: Subcategory,
249 pub amount: i32,
250}
251
252#[derive(Debug, Clone)]
253pub struct Review {
254 pub stars: Option<i32>,
255 pub text: Option<String>,
256 pub reply: Option<String>,
257 pub anonymous: bool,
258 pub html: String,
259 pub hidden: bool,
260 pub order_id: Option<OrderId>,
261 pub author: Option<String>,
262 pub author_id: Option<i64>,
263 pub by_bot: bool,
264 pub reply_by_bot: bool,
265}
266
267#[derive(Debug, Clone)]
268pub struct Subcategory {
269 pub id: Option<i64>,
270 pub name: String,
271}
272
273#[derive(Debug, Clone)]
274pub struct CategorySubcategory {
275 pub id: i64,
276 pub name: String,
277 pub offer_count: u32,
278 pub subcategory_type: CategorySubcategoryType,
279 pub is_active: bool,
280}
281
282#[derive(Debug, Clone, Copy, PartialEq, Eq)]
283pub enum CategorySubcategoryType {
284 Lots,
285 Chips,
286}
287
288#[derive(Debug, Clone)]
289pub struct CategoryFilter {
290 pub id: String,
291 pub name: String,
292 pub filter_type: CategoryFilterType,
293 pub options: Vec<CategoryFilterOption>,
294}
295
296#[derive(Debug, Clone)]
297pub struct CategoryFilterOption {
298 pub value: String,
299 pub label: String,
300}
301
302#[derive(Debug, Clone, Copy, PartialEq, Eq)]
303pub enum CategoryFilterType {
304 Select,
305 RadioBox,
306 Range,
307 Checkbox,
308}
309
310#[derive(Debug, Clone)]
311pub struct Order {
312 pub id: OrderId,
313 pub status: OrderStatus,
314 pub lot_params: Vec<(String, String)>,
315 pub buyer_params: HashMap<String, String>,
316 pub short_description: Option<String>,
317 pub full_description: Option<String>,
318 pub subcategory: Option<Subcategory>,
319 pub amount: i32,
320 pub sum: f64,
321 pub currency: String,
322 pub buyer_id: i64,
323 pub buyer_username: String,
324 pub seller_id: i64,
325 pub seller_username: String,
326 pub chat_id: ChatId,
327 pub html: String,
328 pub review: Option<Review>,
329 pub order_secrets: Vec<String>,
330}