Implemented DLSiteClient.

This commit is contained in:
2025-09-08 17:08:47 -04:00
parent 429252e61f
commit f250276a99
39 changed files with 1584 additions and 173 deletions

View File

@@ -0,0 +1,28 @@
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<VoiceWorkDetailCollection> 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<ProductInfoCollection>(url, ct: cancellationToken);
return DLSiteToDomainMapper.Map(productInfoCollection);
}
}