/*
 * Websocket Subscription Schemas
 *
 * Schema definitions Websocket API subscriptions for Thalex exchange.
 *
 * The version of the OpenAPI document: 1.0.0
 *
 * Generated by: https://openapi-generator.tech
 */

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct OrderFill {
    /// Trade ID.
    #[serde(rename = "trade_id")]
    pub trade_id: String,
    /// Fill price.
    #[serde(rename = "price")]
    pub price: rust_decimal::Decimal,
    /// Filled amount
    #[serde(rename = "amount")]
    pub amount: rust_decimal::Decimal,
    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
    pub time: Option<rust_decimal::Decimal>,
    #[serde(rename = "maker_taker")]
    pub maker_taker: models::MakerTakerEnum,
    /// Index of a leg on which the trade happened for combination orders. Zero for single-leg orders.  For combination orders the direction of the trade is defined by the direction of the order and the sign of the leg quantity.
    #[serde(rename = "leg_index")]
    pub leg_index: rust_decimal::Decimal,
}

impl OrderFill {
    pub fn new(
        trade_id: String,
        price: rust_decimal::Decimal,
        amount: rust_decimal::Decimal,
        maker_taker: models::MakerTakerEnum,
        leg_index: rust_decimal::Decimal,
    ) -> OrderFill {
        OrderFill {
            trade_id,
            price,
            amount,
            time: None,
            maker_taker,
            leg_index,
        }
    }
}
