/*
 * 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 SessionMmProtectionPayloadInner {
    #[serde(rename = "product", skip_serializing_if = "Option::is_none")]
    pub product: Option<String>,
    /// Remaining amount may be less than zero if a single aggressive order has caused an overshoot. If remaining amount is less than or equal to zero, the mass quote orders in the group will have been cancelled, and the group needs refilling.
    #[serde(rename = "remaining_amount", skip_serializing_if = "Option::is_none")]
    pub remaining_amount: Option<rust_decimal::Decimal>,
    /// Detailed reason of the protection group status update.  The following reasons are possible: - `refill`: Remaining amount was updated by the client, e.g. with a call to `private/set_mm_protection`.  - `executions`: Remaining amount was updated after a trade.  - `client_cancel`: Protection group was deleted by the client, e.g. with a call to `private/cancel_mass_quote`.  - `session_end`: Protection group was automatically deleted when a WebSocket session ended.  - `failover`: Protection group was automatically deleted on matching engine failover.
    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
    pub reason: Option<Reason>,
}

impl SessionMmProtectionPayloadInner {
    pub fn new() -> SessionMmProtectionPayloadInner {
        SessionMmProtectionPayloadInner {
            product: None,
            remaining_amount: None,
            reason: None,
        }
    }
}
/// Detailed reason of the protection group status update.  The following reasons are possible: - `refill`: Remaining amount was updated by the client, e.g. with a call to `private/set_mm_protection`.  - `executions`: Remaining amount was updated after a trade.  - `client_cancel`: Protection group was deleted by the client, e.g. with a call to `private/cancel_mass_quote`.  - `session_end`: Protection group was automatically deleted when a WebSocket session ended.  - `failover`: Protection group was automatically deleted on matching engine failover.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Reason {
    #[serde(rename = "refill")]
    Refill,
    #[serde(rename = "executions")]
    Executions,
    #[serde(rename = "client_cancel")]
    ClientCancel,
    #[serde(rename = "session_end")]
    SessionEnd,
    #[serde(rename = "failover")]
    Failover,
}

impl Default for Reason {
    fn default() -> Reason {
        Self::Refill
    }
}
