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

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct AccessLink {
    pub id: RecordId,
    pub vault_id: RecordId,
    pub beneficiary_id: RecordId,
    pub status: AccessLinkStatus,
    pub attempts: u32,
    pub created_at: DateTime<Utc>,
    pub updated_at: DateTime<Utc>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
pub enum AccessLinkStatus {
    #[default]
    Pending,
    Success,
    Failed,
}

impl AccessLinkStatus {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Pending => "PENDING",
            Self::Success => "SUCCESS",
            Self::Failed => "FAILED",
        }
    }
}