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

using CatalogService.Infrastructure;

namespace CatalogService.API.Infrastructure.Tenant;

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

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

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

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