using adas_core.Domain.Models.Responses;

namespace adas_core.Domain.Utils;

/// <summary>
/// Provides a set of static utility methods for authentication-related operations.
/// </summary>
/// <remarks>
/// This class is sealed and cannot be inherited.
/// </remarks>
public sealed class AuthUtils
{
    private LoginResponse _loginResponse = new();

    static AuthUtils()
    {
        InternalInstance ??= new AuthUtils();
    }

    public AuthUtils()
    {
        InternalInstance = this;
    }

    public LoginResponse LoginResponse
    {
        get
        {
            lock (_loginResponse)
            {
                return _loginResponse;
            }
        }
        set
        {
            lock (_loginResponse)
            {
                _loginResponse = value;
            }
        }
    }

    private static AuthUtils InternalInstance { get; set; }
    public static AuthUtils Instance => InternalInstance;

    /// <summary>
    /// Retrieves the current <see cref="LoginResponse"/> in a thread-safe manner by acquiring a lock on the underlying field.
    /// </summary>
    /// <returns>The current <see cref="LoginResponse"/> instance.</returns>
    public LoginResponse GetLoginResponse()
        {
            lock (_loginResponse)
            {
                return _loginResponse;
            }
        }
}