28 lines
1.1 KiB
C#
28 lines
1.1 KiB
C#
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(IHttpService http, ILogger logger) : ApiClient(http, logger), IDLSiteClient
|
|
{
|
|
public async Task<VoiceWorkDetailCollection> GetVoiceWorkDetailsAsync(string[] productIds, CancellationToken cancellationToken = default)
|
|
{
|
|
if (productIds.Length == 0)
|
|
return [];
|
|
|
|
string productIdCollection = string.Join(",", productIds.Where(x => !string.IsNullOrWhiteSpace(x)));
|
|
|
|
if (string.IsNullOrWhiteSpace(productIdCollection))
|
|
return [];
|
|
|
|
string url = $"maniax/product/info/ajax?product_id={productIdCollection}&cdn_cache_min=1";
|
|
|
|
var productInfoCollection = await GetJsonAsync<ProductInfoCollection>(url, cancellationToken);
|
|
|
|
return DLSiteToDomainMapper.Map(productInfoCollection);
|
|
}
|
|
} |