using Flurl.Http; using Recyclarr.Config.Models; using Recyclarr.ServarrApi.Http.Servarr; namespace Recyclarr.ServarrApi.QualityProfile; internal class QualityProfileApiService(IServarrRequestBuilder service) : IQualityProfileApiService { public async Task> GetQualityProfiles(IServiceConfiguration config) { var response = await service.Request(config, "qualityprofile") .GetJsonAsync>(); return response.Select(x => x.ReverseItems()).ToList(); } public async Task GetSchema(IServiceConfiguration config) { var response = await service.Request(config, "qualityprofile", "schema") .GetJsonAsync(); return response.ReverseItems(); } public async Task UpdateQualityProfile(IServiceConfiguration config, QualityProfileDto profile) { if (profile.Id is null) { throw new ArgumentException($"Profile's ID property must not be null: {profile.Name}"); } await service.Request(config, "qualityprofile", profile.Id) .PutJsonAsync(profile.ReverseItems()); } public async Task CreateQualityProfile(IServiceConfiguration config, QualityProfileDto profile) { var response = await service.Request(config, "qualityprofile") .PostJsonAsync(profile.ReverseItems()) .ReceiveJson(); profile.Id = response.Id; } }