using JSMR.Application.Integrations.DLSite.Models; using JSMR.Application.Integrations.Ports; using JSMR.Infrastructure.Http; using JSMR.Infrastructure.Integrations.DLSite.Mapping; using JSMR.Infrastructure.Integrations.DLSite.Models; using Microsoft.Extensions.Logging; namespace JSMR.Infrastructure.Integrations.DLSite; public class DLSiteClient(HttpClient http, ILogger logger) : ApiClient(http, logger), IDLSiteClient { public async Task GetVoiceWorkDetailsAsync(string[] productIds, CancellationToken cancellationToken = default) { if (productIds.Length == 0) throw new Exception("No products to get product information."); string productIdCollection = string.Join(",", productIds.Where(x => !string.IsNullOrWhiteSpace(x))); if (string.IsNullOrWhiteSpace(productIdCollection)) throw new Exception("Invalid product id(s)."); string url = $"maniax/product/info/ajax?product_id={productIdCollection}&cdn_cache_min=1"; var productInfoCollection = await GetJsonAsync(url, ct: cancellationToken); return DLSiteToDomainMapper.Map(productInfoCollection); } }