// EN: Adapter that bridges API-layer ITenantProvider to Infrastructure-layer IFnbTenantProvider.
// VI: Adapter kết nối ITenantProvider tầng API đến IFnbTenantProvider tầng Infrastructure.

using FnbEngine.Infrastructure;

namespace FnbEngine.API.Infrastructure.Tenant;

/// <summary>
/// EN: Adapts the API-layer ITenantProvider to the Infrastructure IFnbTenantProvider interface.
/// VI: Chuyển đổi ITenantProvider tầng API sang interface IFnbTenantProvider tầng Infrastructure.
/// </summary>
public class FnbTenantProviderAdapter : IFnbTenantProvider
{
    private readonly ITenantProvider _tenantProvider;

    public FnbTenantProviderAdapter(ITenantProvider tenantProvider)
    {
        _tenantProvider = tenantProvider ?? throw new ArgumentNullException(nameof(tenantProvider));
    }

    public Guid? GetCurrentShopId() => _tenantProvider.GetCurrentShopId();

    public bool ShouldBypassTenantFilter() =>
        _tenantProvider.IsServiceCall() || _tenantProvider.IsAdmin();
}
