space_traders/models/
market_transaction.rs

1//! Generated by: <https://openapi-generator.tech>
2//!
3//! Version of specification: `2.0.0`
4
5use serde::{Deserialize, Serialize};
6
7/// Result of a transaction with a market.
8#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
9pub struct MarketTransaction {
10    /// The symbol of the waypoint where the transaction took place.
11    #[serde(rename = "waypointSymbol")]
12    pub waypoint_symbol: String,
13    /// The symbol of the ship that made the transaction.
14    #[serde(rename = "shipSymbol")]
15    pub ship_symbol: String,
16    /// The symbol of the trade good.
17    #[serde(rename = "tradeSymbol")]
18    pub trade_symbol: String,
19    /// The type of transaction.
20    #[serde(rename = "type")]
21    pub r#type: Type,
22    /// The number of units of the transaction.
23    #[serde(rename = "units")]
24    pub units: u32,
25    /// The price per unit of the transaction.
26    #[serde(rename = "pricePerUnit")]
27    pub price_per_unit: u32,
28    /// The total price of the transaction.
29    #[serde(rename = "totalPrice")]
30    pub total_price: u32,
31    /// The timestamp of the transaction.
32    #[serde(rename = "timestamp")]
33    pub timestamp: String,
34}
35
36impl MarketTransaction {
37    /// Create value with optional fields set to `None`.
38    #[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/// The type of transaction.
63#[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}