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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct SubaccountDto {
    /// Id representing the registered subaccount
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    /// Bytes32 encoded subaccount name (0x prefix, zero padded)
    #[serde(rename = "name")]
    pub name: String,
    /// Address of the account which registered the subaccount (non-checksummed)
    #[serde(rename = "account")]
    pub account: String,
    /// Block number this subaccount was created on
    #[serde(rename = "createdBlockNumber")]
    pub created_block_number: String,
    /// Block number this subaccount was registered on
    #[serde(
        rename = "registeredBlockNumber",
        skip_serializing_if = "Option::is_none"
    )]
    pub registered_block_number: Option<String>,
    /// Subaccount creation timestamp (ms since Unix Epoch)
    #[serde(rename = "createdAt")]
    pub created_at: f64,
}

impl SubaccountDto {
    pub fn new(
        id: uuid::Uuid,
        name: String,
        account: String,
        created_block_number: String,
        created_at: f64,
    ) -> SubaccountDto {
        SubaccountDto {
            id,
            name,
            account,
            created_block_number,
            registered_block_number: None,
            created_at,
        }
    }
}
