use crate::domain::record_id::RecordId;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct MasterKeyData {
    pub salt: String,
    #[serde(rename = "secretKey")]
    pub secret_key: String,
    #[serde(rename = "createdAt")]
    pub created_at: DateTime<Utc>,
    pub version: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct BeneficiaryKeyData {
    #[serde(rename = "beneficiaryId")]
    pub beneficiary_id: String,
    pub ciphertext: String,
    pub nonce: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct UserVaultKeyData {
    #[serde(rename = "vaultId")]
    pub vault_id: String,
    pub ciphertext: String,
    pub nonce: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct User {
    pub id: RecordId,
    pub email: String,
    pub first_name: String,
    pub last_name: String,
    pub is_first_time: bool,
    pub has_pin_set: bool,
    pub has_accepted_terms: bool,
    pub has_two_factor_auth: bool,
    pub master_key_data: Option<MasterKeyData>,
    pub beneficiary_keys: Option<Vec<BeneficiaryKeyData>>,
    pub vault_keys: Option<Vec<UserVaultKeyData>>,
    pub sync_count: u64,
    pub last_synced_at: Option<DateTime<Utc>>,
    pub last_active_at: Option<DateTime<Utc>>,
    pub created_at: DateTime<Utc>,
    pub updated_at: DateTime<Utc>,
}