Added inital job entity and services. Added released works API integration.
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
using JSMR.Application.Integrations.DLSite.Models;
|
||||
using JSMR.Application.Integrations.Ports;
|
||||
using JSMR.Application.Integrations.DLSite.Models.ReleasedWorks;
|
||||
using JSMR.Application.Integrations.DLSite.Ports;
|
||||
using JSMR.Infrastructure.Globalization;
|
||||
using JSMR.Infrastructure.Http;
|
||||
using JSMR.Infrastructure.Integrations.DLSite.Mapping;
|
||||
using JSMR.Infrastructure.Integrations.DLSite.Models;
|
||||
using JSMR.Infrastructure.Integrations.DLSite.Models.NewWorks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JSMR.Infrastructure.Integrations.DLSite;
|
||||
@@ -23,4 +26,23 @@ public class DLSiteClient(HttpClient http, ILogger<DLSiteClient> logger) : ApiCl
|
||||
|
||||
return DLSiteToDomainMapper.Map(productInfoCollection);
|
||||
}
|
||||
|
||||
public async Task<ReleasedWorksCollection> GetReleasedWorksAsync(ReleasedWorksRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
string locale = LocaleMapper.ToDLSiteLocale(request.Locale);
|
||||
string date = request.Date.ToString("yyyy-MM-dd");
|
||||
string url = $"maniax/new/work/api?locale={locale}&date={date}&period={request.Period}";
|
||||
|
||||
NewWorksApiResponse response = await GetJsonAsync<NewWorksApiResponse>(url, cancellationToken: cancellationToken);
|
||||
|
||||
if (response.Meta.Code != 200)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"DLsite returned code {response.Meta.Code}. " +
|
||||
$"ErrorType: {response.Meta.ErrorType}. " +
|
||||
$"ErrorMessage: {response.Meta.ErrorMessage}");
|
||||
}
|
||||
|
||||
return DLSiteReleasedWorksMapper.Map(response);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user