namespace BookmarkApi.Shared.DTOs.Auth;

/// <summary>
/// 认证响应
/// </summary>
public class AuthResponse
{
    /// <summary>
    /// 是否成功
    /// </summary>
    public bool Success { get; set; }

    /// <summary>
    /// 消息
    /// </summary>
    public string? Message { get; set; }

    /// <summary>
    /// 访问令牌
    /// </summary>
    public string? AccessToken { get; set; }

    /// <summary>
    /// 刷新令牌
    /// </summary>
    public string? RefreshToken { get; set; }

    /// <summary>
    /// 访问令牌过期时间
    /// </summary>
    public DateTime? ExpiresAt { get; set; }

    /// <summary>
    /// 用户信息
    /// </summary>
    public UserDto? User { get; set; }

    /// <summary>
    /// 设备信息
    /// </summary>
    public DeviceDto? Device { get; set; }

    /// <summary>
    /// 创建成功响应
    /// </summary>
    public static AuthResponse Ok(string accessToken, string refreshToken, DateTime expiresAt, UserDto user, DeviceDto device)
    {
        return new AuthResponse
        {
            Success = true,
            AccessToken = accessToken,
            RefreshToken = refreshToken,
            ExpiresAt = expiresAt,
            User = user,
            Device = device
        };
    }

    /// <summary>
    /// 创建失败响应
    /// </summary>
    public static AuthResponse Fail(string message)
    {
        return new AuthResponse
        {
            Success = false,
            Message = message
        };
    }
}

