/*
 * OpenAPI
 *
 * OpenAPI
 *
 * The version of the OpenAPI document: 0.0.1
 *
 * Generated by: https://openapi-generator.tech
 */

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct OrderUpdateMessageDataDInner {
    /// Order identifier.
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    /// Client order identifier provided at order placement. May be empty if not provided or for certain order update types.
    #[serde(rename = "cloid", skip_serializing_if = "Option::is_none")]
    pub cloid: Option<String>,
    #[serde(rename = "otyp")]
    pub otyp: models::OrderType,
    /// Order quantity.
    #[serde(rename = "qty")]
    pub qty: rust_decimal::Decimal,
    /// Available quantity for this order.
    #[serde(rename = "aqty")]
    pub aqty: rust_decimal::Decimal,
    /// Filled quantity for this order.
    #[serde(rename = "fill")]
    pub fill: rust_decimal::Decimal,
    /// Limit price for this order. May be empty for market orders.
    #[serde(rename = "px", skip_serializing_if = "Option::is_none")]
    pub px: Option<rust_decimal::Decimal>,
    #[serde(rename = "sd")]
    pub sd: models::OrderSide,
    /// Market symbol for this order.
    #[serde(rename = "s")]
    pub s: String,
    /// Subaccount identifier for this order.
    #[serde(rename = "sid")]
    pub sid: uuid::Uuid,
    /// Sender address for this order, represented as a hex string. May be empty if not applicable for certain order update types.
    #[serde(rename = "sn")]
    pub sn: String,
    #[serde(rename = "st")]
    pub st: models::OrderStatus,
    #[serde(rename = "t")]
    pub t: i64,
    #[serde(rename = "ro")]
    pub ro: bool,
    #[serde(rename = "cl")]
    pub cl: bool,
    #[serde(rename = "tif", skip_serializing_if = "Option::is_none")]
    pub tif: Option<String>,
    #[serde(rename = "et")]
    pub et: i64,
    #[serde(rename = "po", skip_serializing_if = "Option::is_none")]
    pub po: Option<bool>,
    /// Stop price for stop orders. May be empty for non-stop orders.
    #[serde(rename = "spx", skip_serializing_if = "Option::is_none")]
    pub spx: Option<rust_decimal::Decimal>,
    #[serde(rename = "styp", skip_serializing_if = "Option::is_none")]
    pub styp: Option<i32>,
    #[serde(rename = "spxtyp", skip_serializing_if = "Option::is_none")]
    pub spxtyp: Option<i32>,
    #[serde(rename = "tr")]
    pub tr: String,
    #[serde(rename = "gtyp", skip_serializing_if = "Option::is_none")]
    pub gtyp: Option<i32>,
    #[serde(rename = "gid", skip_serializing_if = "Option::is_none")]
    pub gid: Option<uuid::Uuid>,
}

impl OrderUpdateMessageDataDInner {
    pub fn new(
        id: uuid::Uuid,
        otyp: models::OrderType,
        qty: rust_decimal::Decimal,
        aqty: rust_decimal::Decimal,
        fill: rust_decimal::Decimal,
        sd: models::OrderSide,
        s: String,
        sid: uuid::Uuid,
        sn: String,
        st: models::OrderStatus,
        t: i64,
        ro: bool,
        cl: bool,
        et: i64,
        tr: String,
    ) -> OrderUpdateMessageDataDInner {
        OrderUpdateMessageDataDInner {
            id,
            cloid: None,
            otyp,
            qty,
            aqty,
            fill,
            px: None,
            sd,
            s,
            sid,
            sn,
            st,
            t,
            ro,
            cl,
            tif: None,
            et,
            po: None,
            spx: None,
            styp: None,
            spxtyp: None,
            tr,
            gtyp: None,
            gid: None,
        }
    }
}
