namespace OpenWarehouse.auth.api.Common.CustomIdentifyManager;

public static class AccountTypeFunction
{
    public static string AccountTypeType { get; } = "AccountType";
    
    private static readonly Dictionary<AccountType, string> AccountTypeMap = new()
    {
        { AccountType.User, "User" },
        { AccountType.Admin, "Admin" },
        { AccountType.Service, "Service" },
        { AccountType.Uknow, "Uknow" },
    };

    public static string GetValue(this AccountType accountType)
    {
        var isSuccess = AccountTypeMap.TryGetValue(accountType, out var acountString);

        if (isSuccess &&  acountString != null)
        {
            return acountString;
        }

        throw new Exception("Account type not in AccountTypeMap.");
    }

    public static Claim Claim(this AccountType accountType)
    {
        return new Claim(AccountTypeType, accountType.GetValue());
    }
}