You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
recyclarr/src/Recyclarr.ServarrApi/MediaNaming/MediaNamingApiService.cs

28 lines
938 B

using Flurl.Http;
using Recyclarr.Common;
using Recyclarr.Config.Models;
namespace Recyclarr.ServarrApi.MediaNaming;
public class MediaNamingApiService(IServarrRequestBuilder service) : IMediaNamingApiService
{
public async Task<MediaNamingDto> GetNaming(IServiceConfiguration config)
{
var response = await service.Request(config, "config", "naming")
.GetAsync();
return config.ServiceType switch
{
SupportedServices.Radarr => await response.GetJsonAsync<RadarrMediaNamingDto>(),
SupportedServices.Sonarr => await response.GetJsonAsync<SonarrMediaNamingDto>(),
_ => throw new ArgumentException("Configuration type unsupported in GetNaming() API")
};
}
public async Task UpdateNaming(IServiceConfiguration config, MediaNamingDto dto)
{
await service.Request(config, "config", "naming")
.PutJsonAsync(dto);
}
}