/*
 * Thalex RPC API
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * 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 CryptoWithdrawalsRpcResultInner {
    /// Withdrawn currency symbol.
    #[serde(rename = "currency")]
    pub currency: String,
    /// Amount of currency withdrawn.
    #[serde(rename = "amount")]
    pub amount: rust_decimal::Decimal,
    /// Target address, specific to blockchain used.
    #[serde(rename = "target_address")]
    pub target_address: String,
    /// Blockchain used or this transaction.
    #[serde(rename = "blockchain", skip_serializing_if = "Option::is_none")]
    pub blockchain: Option<String>,
    /// Transaction hash on the used blockchain.
    #[serde(rename = "transaction_hash", skip_serializing_if = "Option::is_none")]
    pub transaction_hash: Option<String>,
    /// Time when this withdrawal was requested (Unix timestamp).
    #[serde(rename = "create_time")]
    pub create_time: rust_decimal::Decimal,
    /// Time when this withdrawal was completed (Unix timestamp).
    #[serde(rename = "execute_time", skip_serializing_if = "Option::is_none")]
    pub execute_time: Option<rust_decimal::Decimal>,
    /// Optional label attached to the withdrawal request.
    #[serde(rename = "label", skip_serializing_if = "Option::is_none")]
    pub label: Option<String>,
    /// Withdrawal transaction status.
    #[serde(rename = "state")]
    pub state: State,
    /// Remark added by the exchange.
    #[serde(rename = "remark", skip_serializing_if = "Option::is_none")]
    pub remark: Option<String>,
    /// Amount of fees withheld.
    #[serde(rename = "fee", skip_serializing_if = "Option::is_none")]
    pub fee: Option<rust_decimal::Decimal>,
    /// Asset in which the withdrawal fees are withheld.
    #[serde(rename = "fee_asset", skip_serializing_if = "Option::is_none")]
    pub fee_asset: Option<String>,
}

impl CryptoWithdrawalsRpcResultInner {
    pub fn new(
        currency: String,
        amount: rust_decimal::Decimal,
        target_address: String,
        create_time: rust_decimal::Decimal,
        state: State,
    ) -> CryptoWithdrawalsRpcResultInner {
        CryptoWithdrawalsRpcResultInner {
            currency,
            amount,
            target_address,
            blockchain: None,
            transaction_hash: None,
            create_time,
            execute_time: None,
            label: None,
            state,
            remark: None,
            fee: None,
            fee_asset: None,
        }
    }
}
/// Withdrawal transaction status.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum State {
    #[serde(rename = "pending")]
    Pending,
    #[serde(rename = "awaiting_confirmation")]
    AwaitingConfirmation,
    #[serde(rename = "executing")]
    Executing,
    #[serde(rename = "executed")]
    Executed,
    #[serde(rename = "rejected")]
    Rejected,
}

impl Default for State {
    fn default() -> State {
        Self::Pending
    }
}
