/*
 * 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};

/// CodeEnum : Extracted enum for CodeEnum
/// Extracted enum for CodeEnum
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum CodeEnum {
    #[serde(rename = "AccountSuspended")]
    AccountSuspended,
    #[serde(rename = "CausesImmediateLiquidation")]
    CausesImmediateLiquidation,
    #[serde(rename = "DuplicateSameSideOco")]
    DuplicateSameSideOco,
    #[serde(rename = "ImmediateMatchPostOnly")]
    ImmediateMatchPostOnly,
    #[serde(rename = "InsufficientBalance")]
    InsufficientBalance,
    #[serde(rename = "LiquidationError")]
    LiquidationError,
    #[serde(rename = "MarketOrderReachedMaxSlippage")]
    MarketOrderReachedMaxSlippage,
    #[serde(rename = "OcoFilled")]
    OcoFilled,
    #[serde(rename = "Ok")]
    Ok,
    #[serde(rename = "OpenValueCapExceeded")]
    OpenValueCapExceeded,
    #[serde(rename = "OrderIncreasesPosition")]
    OrderIncreasesPosition,
    #[serde(rename = "RiskLimitExceeded")]
    RiskLimitExceeded,
    #[serde(rename = "SignerRevoked")]
    SignerRevoked,
    #[serde(rename = "TriggerCanceledError")]
    TriggerCanceledError,
    #[serde(rename = "UnfilledFillOrKill")]
    UnfilledFillOrKill,
    #[serde(rename = "UnfilledImmediateOrCancel")]
    UnfilledImmediateOrCancel,
    #[serde(rename = "UnfilledMarketOrder")]
    UnfilledMarketOrder,
}

impl std::fmt::Display for CodeEnum {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        match self {
            Self::AccountSuspended => write!(f, "AccountSuspended"),
            Self::CausesImmediateLiquidation => write!(f, "CausesImmediateLiquidation"),
            Self::DuplicateSameSideOco => write!(f, "DuplicateSameSideOco"),
            Self::ImmediateMatchPostOnly => write!(f, "ImmediateMatchPostOnly"),
            Self::InsufficientBalance => write!(f, "InsufficientBalance"),
            Self::LiquidationError => write!(f, "LiquidationError"),
            Self::MarketOrderReachedMaxSlippage => write!(f, "MarketOrderReachedMaxSlippage"),
            Self::OcoFilled => write!(f, "OcoFilled"),
            Self::Ok => write!(f, "Ok"),
            Self::OpenValueCapExceeded => write!(f, "OpenValueCapExceeded"),
            Self::OrderIncreasesPosition => write!(f, "OrderIncreasesPosition"),
            Self::RiskLimitExceeded => write!(f, "RiskLimitExceeded"),
            Self::SignerRevoked => write!(f, "SignerRevoked"),
            Self::TriggerCanceledError => write!(f, "TriggerCanceledError"),
            Self::UnfilledFillOrKill => write!(f, "UnfilledFillOrKill"),
            Self::UnfilledImmediateOrCancel => write!(f, "UnfilledImmediateOrCancel"),
            Self::UnfilledMarketOrder => write!(f, "UnfilledMarketOrder"),
        }
    }
}

impl Default for CodeEnum {
    fn default() -> CodeEnum {
        Self::AccountSuspended
    }
}
