space-traders 0.1.1

Async SpaceTraders API client for Rust.
Documentation
//! Generated by: <https://openapi-generator.tech>
//!
//! Version of specification: `2.0.0`

use serde::{Deserialize, Serialize};

/// Result of a transaction with a market.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MarketTransaction {
    /// The symbol of the waypoint where the transaction took place.
    #[serde(rename = "waypointSymbol")]
    pub waypoint_symbol: String,
    /// The symbol of the ship that made the transaction.
    #[serde(rename = "shipSymbol")]
    pub ship_symbol: String,
    /// The symbol of the trade good.
    #[serde(rename = "tradeSymbol")]
    pub trade_symbol: String,
    /// The type of transaction.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The number of units of the transaction.
    #[serde(rename = "units")]
    pub units: u32,
    /// The price per unit of the transaction.
    #[serde(rename = "pricePerUnit")]
    pub price_per_unit: u32,
    /// The total price of the transaction.
    #[serde(rename = "totalPrice")]
    pub total_price: u32,
    /// The timestamp of the transaction.
    #[serde(rename = "timestamp")]
    pub timestamp: String,
}

impl MarketTransaction {
    /// Create value with optional fields set to `None`.
    #[allow(clippy::too_many_arguments)]
    pub fn new(
        waypoint_symbol: String,
        ship_symbol: String,
        trade_symbol: String,
        r#type: Type,
        units: u32,
        price_per_unit: u32,
        total_price: u32,
        timestamp: String,
    ) -> MarketTransaction {
        MarketTransaction {
            waypoint_symbol,
            ship_symbol,
            trade_symbol,
            r#type,
            units,
            price_per_unit,
            total_price,
            timestamp,
        }
    }
}

/// The type of transaction.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "PURCHASE")]
    Purchase,
    #[serde(rename = "SELL")]
    Sell,
}

impl Default for Type {
    fn default() -> Type {
        Self::Purchase
    }
}