space_traders_api/models/
market_transaction.rs

1/*
2 * SpaceTraders API
3 *
4 * SpaceTraders is an open-universe game and learning platform that offers a set of HTTP endpoints to control a fleet of ships and explore a multiplayer universe.  The API is documented using [OpenAPI](https://github.com/SpaceTradersAPI/api-docs). You can send your first request right here in your browser to check the status of the game server.  ```json http {   \"method\": \"GET\",   \"url\": \"https://api.spacetraders.io/v2\", } ```  Unlike a traditional game, SpaceTraders does not have a first-party client or app to play the game. Instead, you can use the API to build your own client, write a script to automate your ships, or try an app built by the community.  We have a [Discord channel](https://discord.com/invite/jh6zurdWk5) where you can share your projects, ask questions, and get help from other players.   
5 *
6 * The version of the OpenAPI document: 2.3.0
7 * Contact: joel@spacetraders.io
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// MarketTransaction : Result of a transaction with a market.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct MarketTransaction {
17    /// The symbol of the waypoint.
18    #[serde(rename = "waypointSymbol")]
19    pub waypoint_symbol: String,
20    /// The symbol of the ship that made the transaction.
21    #[serde(rename = "shipSymbol")]
22    pub ship_symbol: String,
23    /// The symbol of the trade good.
24    #[serde(rename = "tradeSymbol")]
25    pub trade_symbol: String,
26    /// The type of transaction.
27    #[serde(rename = "type")]
28    pub r#type: Type,
29    /// The number of units of the transaction.
30    #[serde(rename = "units")]
31    pub units: i32,
32    /// The price per unit of the transaction.
33    #[serde(rename = "pricePerUnit")]
34    pub price_per_unit: i32,
35    /// The total price of the transaction.
36    #[serde(rename = "totalPrice")]
37    pub total_price: i32,
38    /// The timestamp of the transaction.
39    #[serde(rename = "timestamp")]
40    pub timestamp: String,
41}
42
43impl MarketTransaction {
44    /// Result of a transaction with a market.
45    pub fn new(waypoint_symbol: String, ship_symbol: String, trade_symbol: String, r#type: Type, units: i32, price_per_unit: i32, total_price: i32, timestamp: String) -> MarketTransaction {
46        MarketTransaction {
47            waypoint_symbol,
48            ship_symbol,
49            trade_symbol,
50            r#type,
51            units,
52            price_per_unit,
53            total_price,
54            timestamp,
55        }
56    }
57}
58/// The type of transaction.
59#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
60pub enum Type {
61    #[serde(rename = "PURCHASE")]
62    Purchase,
63    #[serde(rename = "SELL")]
64    Sell,
65}
66
67impl Default for Type {
68    fn default() -> Type {
69        Self::Purchase
70    }
71}
72