// EN: Command to handle external login callback
// VI: Command xử lý callback external login
using MediatR;

namespace IamService.API.Application.Commands.Auth;

/// <summary>
/// EN: Command to process external login from OAuth providers.
/// VI: Command xử lý external login từ OAuth providers.
/// </summary>
/// <param name="Provider">OAuth provider name (Google, Facebook)</param>
/// <param name="ProviderUserId">User ID from the provider</param>
/// <param name="Email">User email from provider</param>
/// <param name="Name">User name from provider</param>
/// <param name="PictureUrl">Profile picture URL</param>
public record ExternalLoginCommand(
    string Provider,
    string ProviderUserId,
    string Email,
    string? Name,
    string? PictureUrl) : IRequest<ExternalLoginResult>;

/// <summary>
/// EN: Result of external login command.
/// VI: Kết quả của command external login.
/// </summary>
public record ExternalLoginResult
{
    /// <summary>
    /// EN: Whether login was successful.
    /// VI: Đăng nhập có thành công không.
    /// </summary>
    public bool Success { get; init; }

    /// <summary>
    /// EN: Error message if login failed.
    /// VI: Thông báo lỗi nếu đăng nhập thất bại.
    /// </summary>
    public string Message { get; init; } = string.Empty;

    /// <summary>
    /// EN: User ID if successful.
    /// VI: User ID nếu thành công.
    /// </summary>
    public Guid? UserId { get; init; }

    /// <summary>
    /// EN: User email.
    /// VI: Email của user.
    /// </summary>
    public string? Email { get; init; }

    /// <summary>
    /// EN: Whether this is a new user registration.
    /// VI: Đây có phải đăng ký user mới không.
    /// </summary>
    public bool IsNewUser { get; init; }

    /// <summary>
    /// EN: Access token for the user.
    /// VI: Access token cho user.
    /// </summary>
    public string? AccessToken { get; init; }

    /// <summary>
    /// EN: Refresh token for the user.
    /// VI: Refresh token cho user.
    /// </summary>
    public string? RefreshToken { get; init; }
}
