space_traders/models/
market_transaction.rs1use serde::{Deserialize, Serialize};
6
7#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
9pub struct MarketTransaction {
10 #[serde(rename = "waypointSymbol")]
12 pub waypoint_symbol: String,
13 #[serde(rename = "shipSymbol")]
15 pub ship_symbol: String,
16 #[serde(rename = "tradeSymbol")]
18 pub trade_symbol: String,
19 #[serde(rename = "type")]
21 pub r#type: Type,
22 #[serde(rename = "units")]
24 pub units: u32,
25 #[serde(rename = "pricePerUnit")]
27 pub price_per_unit: u32,
28 #[serde(rename = "totalPrice")]
30 pub total_price: u32,
31 #[serde(rename = "timestamp")]
33 pub timestamp: String,
34}
35
36impl MarketTransaction {
37 #[allow(clippy::too_many_arguments)]
39 pub fn new(
40 waypoint_symbol: String,
41 ship_symbol: String,
42 trade_symbol: String,
43 r#type: Type,
44 units: u32,
45 price_per_unit: u32,
46 total_price: u32,
47 timestamp: String,
48 ) -> MarketTransaction {
49 MarketTransaction {
50 waypoint_symbol,
51 ship_symbol,
52 trade_symbol,
53 r#type,
54 units,
55 price_per_unit,
56 total_price,
57 timestamp,
58 }
59 }
60}
61
62#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
64pub enum Type {
65 #[serde(rename = "PURCHASE")]
66 Purchase,
67 #[serde(rename = "SELL")]
68 Sell,
69}
70
71impl Default for Type {
72 fn default() -> Type {
73 Self::Purchase
74 }
75}