using Meezi.Core.Authorization;
using Meezi.Core.Entities;
using Meezi.Core.Enums;

namespace Meezi.API.Services;

public interface IJwtTokenService
{
    string CreateAccessToken(Employee employee, Cafe cafe);

    /// <summary>
    /// Issue a token scoped to an active branch. The <paramref name="effectiveRole"/>
    /// is the role the employee holds in <paramref name="activeBranchId"/> (or their
    /// café-wide role when <paramref name="activeBranchId"/> is null).
    /// When <paramref name="customPermissions"/> is non-null the token embeds those
    /// permissions as a claim that overrides the role matrix on the server side.
    /// </summary>
    string CreateAccessToken(
        Employee employee,
        Cafe cafe,
        EmployeeRole effectiveRole,
        string? activeBranchId,
        IEnumerable<Permission>? customPermissions = null);

    string CreateConsumerAccessToken(ConsumerAccount account, string language = "fa");
    string CreateRefreshToken();
    DateTime GetAccessTokenExpiry();
}

public record TokenPair(string AccessToken, string RefreshToken, DateTime AccessTokenExpiresAt);
