/*
 * 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 TransactionHistoryRpcResultTransactionsInner {
    /// Timestamp when the transaction was performed.  For actions that produce multiple transactions (e.g. asset swaps, internal transfers), all transactions will have the same timestamp.
    #[serde(rename = "time")]
    pub time: rust_decimal::Decimal,
    /// Asset name.
    #[serde(rename = "asset")]
    pub asset: String,
    /// Amount credited (positive number) or debited (negative number).
    #[serde(rename = "amount")]
    pub amount: rust_decimal::Decimal,
    /// Instrument name this transaction relates to. For example, settlement transactions are per instrument.  Not included for transactions that don't relate to an instrument.
    #[serde(rename = "instrument_name", skip_serializing_if = "Option::is_none")]
    pub instrument_name: Option<String>,
    /// Transaction type. Can be one of the following values: - `credit` - Asset credits or debits. - `deposit` - Deposits. - `withdrawal` - Withdrawals. - `withdrawal fee` - Withdrawal fees. - `session settlement` - Settled session PNL. - `perpetual funding` - Settled perpetual funding. - `internal transfer` - Transfer of assets between sub-accounts. One transaction in each sub-account per asset per transfer. - `asset swap` - Swap between assets. One transaction for each side of the asset pair per swap. - `referral program payment` - Referral program rewards. - `market velocity program payment` - MVP program rewards. - `market quality program payment` - MQP program rewards. - `daily interest` - Daily penalty charge for negative balance. Not applied anymore, but can be found in historical transactions. - `balance sweep` - Balance sweep between two accounts.
    #[serde(rename = "transaction_type", skip_serializing_if = "Option::is_none")]
    pub transaction_type: Option<TransactionType>,
    /// Description of this transaction.  Note that this field is not supposed to be machine-readable and the the format is not guaranteed to remain unchanged.
    #[serde(rename = "description")]
    pub description: String,
    /// Account balance in this asset right after transaction.
    #[serde(rename = "balance_after", skip_serializing_if = "Option::is_none")]
    pub balance_after: Option<rust_decimal::Decimal>,
    #[serde(rename = "structured_data", skip_serializing_if = "Option::is_none")]
    pub structured_data: Option<models::TransactionHistoryRpcResultTransactionsInnerStructuredData>,
}

impl TransactionHistoryRpcResultTransactionsInner {
    pub fn new(
        time: rust_decimal::Decimal,
        asset: String,
        amount: rust_decimal::Decimal,
        description: String,
    ) -> TransactionHistoryRpcResultTransactionsInner {
        TransactionHistoryRpcResultTransactionsInner {
            time,
            asset,
            amount,
            instrument_name: None,
            transaction_type: None,
            description,
            balance_after: None,
            structured_data: None,
        }
    }
}
/// Transaction type. Can be one of the following values: - `credit` - Asset credits or debits. - `deposit` - Deposits. - `withdrawal` - Withdrawals. - `withdrawal fee` - Withdrawal fees. - `session settlement` - Settled session PNL. - `perpetual funding` - Settled perpetual funding. - `internal transfer` - Transfer of assets between sub-accounts. One transaction in each sub-account per asset per transfer. - `asset swap` - Swap between assets. One transaction for each side of the asset pair per swap. - `referral program payment` - Referral program rewards. - `market velocity program payment` - MVP program rewards. - `market quality program payment` - MQP program rewards. - `daily interest` - Daily penalty charge for negative balance. Not applied anymore, but can be found in historical transactions. - `balance sweep` - Balance sweep between two accounts.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum TransactionType {
    #[serde(rename = "credit")]
    Credit,
    #[serde(rename = "deposit")]
    Deposit,
    #[serde(rename = "withdrawal")]
    Withdrawal,
    #[serde(rename = "withdrawal fee")]
    WithdrawalFee,
    #[serde(rename = "session settlement")]
    SessionSettlement,
    #[serde(rename = "perpetual funding")]
    PerpetualFunding,
    #[serde(rename = "internal transfer")]
    InternalTransfer,
    #[serde(rename = "asset swap")]
    AssetSwap,
    #[serde(rename = "referral program payment")]
    ReferralProgramPayment,
    #[serde(rename = "market velocity program payment")]
    MarketVelocityProgramPayment,
    #[serde(rename = "market quality program payment")]
    MarketQualityProgramPayment,
    #[serde(rename = "daily interest")]
    DailyInterest,
    #[serde(rename = "balance sweep")]
    BalanceSweep,
}

impl Default for TransactionType {
    fn default() -> TransactionType {
        Self::Credit
    }
}
