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.TrashLib/Pipelines/CustomFormat/Api/CustomFormatService.cs

42 lines
1.3 KiB

using Flurl.Http;
using Recyclarr.TrashLib.Config.Services;
using Recyclarr.TrashLib.Http;
using Recyclarr.TrashLib.Pipelines.CustomFormat.Models;
namespace Recyclarr.TrashLib.Pipelines.CustomFormat.Api;
public class CustomFormatService : ICustomFormatService
{
private readonly IServiceRequestBuilder _service;
public CustomFormatService(IServiceRequestBuilder service)
{
_service = service;
}
public async Task<IList<CustomFormatData>> GetCustomFormats(IServiceConfiguration config)
{
return await _service.Request(config, "customformat")
.GetJsonAsync<IList<CustomFormatData>>();
}
public async Task<CustomFormatData?> CreateCustomFormat(IServiceConfiguration config, CustomFormatData cf)
{
return await _service.Request(config, "customformat")
.PostJsonAsync(cf)
.ReceiveJson<CustomFormatData>();
}
public async Task UpdateCustomFormat(IServiceConfiguration config, CustomFormatData cf)
{
await _service.Request(config, "customformat", cf.Id)
.PutJsonAsync(cf);
}
public async Task DeleteCustomFormat(IServiceConfiguration config, int customFormatId)
{
await _service.Request(config, "customformat", customFormatId)
.DeleteAsync();
}
}