/*
 * Ethereal Exchange API
 *
 * Ethereal HTTP API for real-time trading, order management, and market data access.
 *
 * The version of the OpenAPI document: 0.1.0
 *
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct TradeDto {
    /// Id representing the trade
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    /// Id of the taker order
    #[serde(rename = "takerOrderId")]
    pub taker_order_id: uuid::Uuid,
    /// Id of the maker order
    #[serde(rename = "makerOrderId")]
    pub maker_order_id: uuid::Uuid,
    /// Client-generated order id of the taker order
    #[serde(rename = "takerClientOrderId", skip_serializing_if = "Option::is_none")]
    pub taker_client_order_id: Option<String>,
    /// Client-generated order id of the maker order
    #[serde(rename = "makerClientOrderId", skip_serializing_if = "Option::is_none")]
    pub maker_client_order_id: Option<String>,
    /// Maker fee in USD expressed as a decimal (precision: 9)
    #[serde(rename = "makerFeeUsd")]
    pub maker_fee_usd: String,
    /// Taker fee in USD expressed as a decimal (precision: 9)
    #[serde(rename = "takerFeeUsd")]
    pub taker_fee_usd: String,
    /// Price expressed as a decimal (precision: 9)
    #[serde(rename = "price")]
    pub price: String,
    /// Quantity filled in native units expressed as a decimal (precision: 9)
    #[serde(rename = "filled")]
    pub filled: String,
    #[serde(rename = "makerSide")]
    pub maker_side: models::MakerSideEnum,
    #[serde(rename = "takerSide")]
    pub taker_side: models::TakerSideEnum,
    /// Id of product the trade was made against
    #[serde(rename = "productId")]
    pub product_id: uuid::Uuid,
    /// Trade creation timestamp (ms since Unix Epoch)
    #[serde(rename = "createdAt")]
    pub created_at: i64,
}

impl TradeDto {
    pub fn new(
        id: uuid::Uuid,
        taker_order_id: uuid::Uuid,
        maker_order_id: uuid::Uuid,
        maker_fee_usd: String,
        taker_fee_usd: String,
        price: String,
        filled: String,
        maker_side: models::MakerSideEnum,
        taker_side: models::TakerSideEnum,
        product_id: uuid::Uuid,
        created_at: i64,
    ) -> TradeDto {
        TradeDto {
            id,
            taker_order_id,
            maker_order_id,
            taker_client_order_id: None,
            maker_client_order_id: None,
            maker_fee_usd,
            taker_fee_usd,
            price,
            filled,
            maker_side,
            taker_side,
            product_id,
            created_at,
        }
    }
}
