using JSMR.Application.Integrations.Chobit.Models;
using JSMR.Application.Integrations.Chobit.Ports;
using JSMR.Infrastructure.Http;
using Microsoft.Extensions.Logging;

namespace JSMR.Infrastructure.Integrations.Chobit;

public class ChobitClient(HttpClient http, ILogger<ChobitClient> logger) : ApiClient(http, logger), IChobitClient
{
    public Task<ChobitResult> GetSampleInfoAsync(string productId, CancellationToken cancellationToken = default)
    {
        var url = $"api/v1/dlsite/embed?workno={productId}";
        return GetJsonpAsync<ChobitResult>(url, cancellationToken: cancellationToken);
    }

    public Task<ChobitResultCollection> GetSampleInfoAsync(string[] productIds, CancellationToken cancellationToken = default)
    {
        var url = $"api/v2/dlsite/embed?workno_list={string.Join(",", productIds)}";
        return GetJsonpAsync<ChobitResultCollection>(url, cancellationToken: cancellationToken);
    }
}