public async Task Send_v2_to_v1() { using var ctx = new TestContext(); var compat = Substitute.For <ISonarrCompatibility>(); compat.Capabilities.Returns(new[] { new SonarrCapabilities { ArraysNeededForReleaseProfileRequiredAndIgnored = false } }.ToObservable()); var data = new SonarrReleaseProfile { Ignored = new List <string> { "one", "two", "three" } }; var sut = new SonarrReleaseProfileCompatibilityHandler(compat, ctx.Mapper); var result = await sut.CompatibleReleaseProfileForSendingAsync(data); result.Should().BeEquivalentTo(new SonarrReleaseProfileV1 { Ignored = "one,two,three" }); }
public async Task <SonarrReleaseProfile> CreateReleaseProfile(SonarrReleaseProfile newProfile) { return(await BaseUrl() .AppendPathSegment("releaseprofile") .PostJsonAsync(newProfile) .ReceiveJson <SonarrReleaseProfile>()); }
private async Task UpdateExistingProfile(SonarrReleaseProfile profileToUpdate, FilteredProfileData profile, List <int> tagIds) { Log.Debug("Update existing profile with id {ProfileId}", profileToUpdate.Id); SetupProfileRequestObject(profileToUpdate, profile, tagIds); await _api.UpdateReleaseProfile(profileToUpdate); }
public async Task UpdateReleaseProfile(SonarrReleaseProfile profileToUpdate) { var profileToSend = await _profileHandler.CompatibleReleaseProfileForSendingAsync(profileToUpdate); await BaseUrl() .AppendPathSegment($"releaseprofile/{profileToUpdate.Id}") .PutJsonAsync(profileToSend); }
public async Task <object> CompatibleReleaseProfileForSendingAsync(SonarrReleaseProfile profile) { var capabilities = await _compatibility.Capabilities.LastAsync(); return(capabilities.ArraysNeededForReleaseProfileRequiredAndIgnored ? profile : _mapper.Map <SonarrReleaseProfileV1>(profile)); }
public async Task <SonarrReleaseProfile> CreateReleaseProfile(SonarrReleaseProfile newProfile) { var profileToSend = await _profileHandler.CompatibleReleaseProfileForSendingAsync(newProfile); var response = await BaseUrl() .AppendPathSegment("releaseprofile") .PostJsonAsync(profileToSend) .ReceiveJson <JObject>(); return(_profileHandler.CompatibleReleaseProfileForReceiving(response)); }
private async Task CreateNewProfile(string title, FilteredProfileData profile, List <int> tagIds) { var newProfile = new SonarrReleaseProfile { Name = title, Enabled = true }; SetupProfileRequestObject(newProfile, profile, tagIds); await _api.CreateReleaseProfile(newProfile); }
public void Receive_v2_to_v2() { using var ctx = new TestContext(); var compat = Substitute.For <ISonarrCompatibility>(); var dataV2 = new SonarrReleaseProfile { Ignored = new List <string> { "one", "two", "three" } }; var sut = new SonarrReleaseProfileCompatibilityHandler(compat, ctx.Mapper); var result = sut.CompatibleReleaseProfileForReceiving(JObject.Parse(ctx.SerializeJson(dataV2))); result.Should().BeEquivalentTo(dataV2); }
private static void SetupProfileRequestObject(SonarrReleaseProfile profileToUpdate, FilteredProfileData profile, List <int> tagIds) { profileToUpdate.Preferred = profile.Preferred .SelectMany(kvp => kvp.Value.Select(term => new SonarrPreferredTerm(kvp.Key, term))) .ToList(); profileToUpdate.Ignored = string.Join(',', profile.Ignored); profileToUpdate.Required = string.Join(',', profile.Required); // Null means the guide didn't specify a value for this, so we leave the existing setting intact. if (profile.IncludePreferredWhenRenaming != null) { profileToUpdate.IncludePreferredWhenRenaming = profile.IncludePreferredWhenRenaming.Value; } profileToUpdate.Tags = tagIds; }
public async Task UpdateReleaseProfile(SonarrReleaseProfile profileToUpdate) { await BaseUrl() .AppendPathSegment($"releaseprofile/{profileToUpdate.Id}") .PutJsonAsync(profileToUpdate); }