From a744a37ec9247f4e018d7f134ea419f139855135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Fr=C3=B6hling?= Date: Sun, 2 Apr 2023 00:40:40 +0000 Subject: [PATCH] GH-376: Use `ITraktSyncRecommendationsRemovePost` instead of `ITraktSyncRecommendationsPost` --- .../Lib/Trakt.NET/Modules/TraktSyncModule.cs | 12 ++-- .../OAuth/SyncRecommendationsRemoveRequest.cs | 2 +- ...ule_RemovePersonalRecommendations_Tests.cs | 4 +- .../TraktSyncModule_Tests_Setup.cs | 62 +++++++++++++++++++ 4 files changed, 71 insertions(+), 9 deletions(-) diff --git a/Source/Lib/Trakt.NET/Modules/TraktSyncModule.cs b/Source/Lib/Trakt.NET/Modules/TraktSyncModule.cs index 23180cfc04..60676ec4d5 100644 --- a/Source/Lib/Trakt.NET/Modules/TraktSyncModule.cs +++ b/Source/Lib/Trakt.NET/Modules/TraktSyncModule.cs @@ -645,12 +645,12 @@ public Task RemovePlaybackItemAsync(uint playbackId, Can /// See "Trakt API Doc - Sync: Remove from Personal Recommendations" for more information. /// /// - /// It is recommended to use the to create an instance - /// of the required . - /// See also . + /// It is recommended to use the to create an instance + /// of the required . + /// See also . /// /// - /// An instance containing all movies and shows, which should be removed. + /// An instance containing all movies and shows, which should be removed. /// /// Propagates notification that the request should be canceled. /// If provided, the exception should be catched. @@ -659,14 +659,14 @@ public Task RemovePlaybackItemAsync(uint playbackId, Can /// Thrown, if the request fails. /// Thrown, if validation of post data fails. /// Thrown, if validation of request data fails. - public Task> RemovePersonalRecommendationsAsync(ITraktSyncRecommendationsPost recommendationsPost, + public Task> RemovePersonalRecommendationsAsync(ITraktSyncRecommendationsRemovePost recommendationsRemovePost, CancellationToken cancellationToken = default) { var requestHandler = new RequestHandler(Client); return requestHandler.ExecuteSingleItemRequestAsync(new SyncRecommendationsRemoveRequest { - RequestBody = recommendationsPost + RequestBody = recommendationsRemovePost }, cancellationToken); } diff --git a/Source/Lib/Trakt.NET/Requests/Syncs/OAuth/SyncRecommendationsRemoveRequest.cs b/Source/Lib/Trakt.NET/Requests/Syncs/OAuth/SyncRecommendationsRemoveRequest.cs index 4b3c8e33aa..9643471827 100644 --- a/Source/Lib/Trakt.NET/Requests/Syncs/OAuth/SyncRecommendationsRemoveRequest.cs +++ b/Source/Lib/Trakt.NET/Requests/Syncs/OAuth/SyncRecommendationsRemoveRequest.cs @@ -3,7 +3,7 @@ using Objects.Post.Syncs.Recommendations; using Objects.Post.Syncs.Recommendations.Responses; - internal class SyncRecommendationsRemoveRequest : ASyncPostRequest + internal class SyncRecommendationsRemoveRequest : ASyncPostRequest { public override string UriTemplate => "sync/recommendations/remove"; } diff --git a/Source/Tests/Trakt.NET.Modules.Tests/TraktSyncModule/TraktSyncModule_RemovePersonalRecommendations_Tests.cs b/Source/Tests/Trakt.NET.Modules.Tests/TraktSyncModule/TraktSyncModule_RemovePersonalRecommendations_Tests.cs index d4ddac47a5..1ce0a86bc3 100644 --- a/Source/Tests/Trakt.NET.Modules.Tests/TraktSyncModule/TraktSyncModule_RemovePersonalRecommendations_Tests.cs +++ b/Source/Tests/Trakt.NET.Modules.Tests/TraktSyncModule/TraktSyncModule_RemovePersonalRecommendations_Tests.cs @@ -25,7 +25,7 @@ public async Task Test_TraktSyncModule_RemovePersonalRecommendations() postJson.Should().NotBeNullOrEmpty(); TraktClient client = TestUtility.GetOAuthMockClient(REMOVE_RECOMMENDATIONS_URI, postJson, RECOMMENDATIONS_REMOVE_POST_RESPONSE_JSON); - TraktResponse response = await client.Sync.RemovePersonalRecommendationsAsync(RecommendationsPost); + TraktResponse response = await client.Sync.RemovePersonalRecommendationsAsync(RemoveRecommendationsPost); response.Should().NotBeNull(); response.IsSuccess.Should().BeTrue(); @@ -87,7 +87,7 @@ public async Task Test_TraktSyncModule_RemovePersonalRecommendations_Throws_API_ try { - await client.Sync.RemovePersonalRecommendationsAsync(RecommendationsPost); + await client.Sync.RemovePersonalRecommendationsAsync(RemoveRecommendationsPost); Assert.False(true); } catch (Exception exception) diff --git a/Source/Tests/Trakt.NET.Modules.Tests/TraktSyncModule/TraktSyncModule_Tests_Setup.cs b/Source/Tests/Trakt.NET.Modules.Tests/TraktSyncModule/TraktSyncModule_Tests_Setup.cs index 4c7e7b7fc8..0687b2d041 100644 --- a/Source/Tests/Trakt.NET.Modules.Tests/TraktSyncModule/TraktSyncModule_Tests_Setup.cs +++ b/Source/Tests/Trakt.NET.Modules.Tests/TraktSyncModule/TraktSyncModule_Tests_Setup.cs @@ -16,6 +16,7 @@ public partial class TraktSyncModule_Tests private ITraktSyncCollectionPost AddCollectionItemsPost { get; } private ITraktSyncRatingsPost AddRatingsPost { get; } private ITraktSyncRecommendationsPost RecommendationsPost { get; } + private ITraktSyncRecommendationsRemovePost RemoveRecommendationsPost { get; } private ITraktSyncHistoryPost AddHistoryPost { get; } private ITraktSyncWatchlistPost AddWatchlistPost { get; } private ITraktSyncCollectionRemovePost RemoveCollectionItemsPost { get; } @@ -28,6 +29,7 @@ public TraktSyncModule_Tests() AddCollectionItemsPost = SetupAddCollectionItemsPost(); AddRatingsPost = SetupAddRatingsPost(); RecommendationsPost = SetupAddRecommendationsPost(); + RemoveRecommendationsPost = SetupAddRecommendationsRemovePost(); AddHistoryPost = SetupAddHistoryPost(); AddWatchlistPost = SetupAddWatchlistPost(); RemoveCollectionItemsPost = SetupRemoveCollectionItemsPost(); @@ -331,6 +333,66 @@ private ITraktSyncRecommendationsPost SetupAddRecommendationsPost() }; } + private ITraktSyncRecommendationsRemovePost SetupAddRecommendationsRemovePost() + { + return new TraktSyncRecommendationsRemovePost + { + Movies = new List + { + new TraktSyncRecommendationsPostMovie + { + Title = "Batman Begins", + Year = 2005, + Ids = new TraktMovieIds + { + Trakt = 1, + Slug = "batman-begins-2005", + Imdb = "tt0372784", + Tmdb = 272 + }, + Notes = "One of Chritian Bale's most iconic roles." + }, + new TraktSyncRecommendationsPostMovie + { + Ids = new TraktMovieIds + { + Imdb = "tt0000111" + } + } + }, + Shows = new List + { + new TraktSyncRecommendationsPostShow + { + Title = "Breaking Bad", + Year = 2008, + Ids = new TraktShowIds + { + Trakt = 1, + Slug = "breaking-bad", + Tvdb = 81189, + Imdb = "tt0903747", + Tmdb = 1396 + }, + Notes = "I AM THE DANGER!" + }, + new TraktSyncRecommendationsPostShow + { + Title = "The Walking Dead", + Year = 2010, + Ids = new TraktShowIds + { + Trakt = 2, + Slug = "the-walking-dead", + Tvdb = 153021, + Imdb = "tt1520211", + Tmdb = 1402 + } + } + } + }; + } + private ITraktSyncHistoryPost SetupAddHistoryPost() { return new TraktSyncHistoryPost