using System.Text.Json;
using System.Text.Json.Serialization;
using Common.Security.Infrastructure;
using Microsoft.Extensions.Configuration;

namespace Modules.Library.Application.Gateways;

public class UserGateway: IUserGateway
{
    private readonly IHttpClientFactory _httpClientFactory;
    private readonly UserContext _userContext;
    private readonly string _baseAddress;

    public UserClient(IHttpClientFactory httpClientFactory, UserContext userContext, IConfiguration configuration)
    {
        _httpClientFactory = httpClientFactory;
        _userContext = userContext;
        _baseAddress = configuration["Services:User:BaseUrl"] ?? string.Empty;
    }
    
    public async ValueTask<Guid?> TryGetUserId(CancellationToken cancellationToken)
    {
        var accountId = _userContext.GetAccountId();
        if (!accountId.HasValue) return null;
        using var client = 
        return await _users.GetByAccountIdAsync(accountId, ct);
    }
}