Skip to content

Commit

Permalink
Merge pull request #583 from henrikfroehling/issue/release-1.4.0/GH-556
Browse files Browse the repository at this point in the history
Resolves GH-556
  • Loading branch information
henrikfroehling authored Jul 22, 2023
2 parents e36b1b9 + e26211b commit 1f8d158
Show file tree
Hide file tree
Showing 165 changed files with 2,886 additions and 4,419 deletions.
86 changes: 43 additions & 43 deletions Source/Lib/Trakt.NET/Modules/TraktSyncModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ namespace TraktNet.Modules
using Objects.Post.Syncs.History.Responses;
using Objects.Post.Syncs.Ratings;
using Objects.Post.Syncs.Ratings.Responses;
using Objects.Post.Syncs.Recommendations;
using Objects.Post.Syncs.Recommendations.Responses;
using Objects.Post.Syncs.Favorites;
using Objects.Post.Syncs.Favorites.Responses;
using Objects.Post.Syncs.Watchlist;
using Objects.Post.Syncs.Watchlist.Responses;
using PostBuilder;
Expand Down Expand Up @@ -64,20 +64,20 @@ public Task<TraktResponse<ITraktSyncLastActivities>> GetLastActivitiesAsync(Canc
}

/// <summary>
/// Gets an user's personal recommendations for movies and / or shows.
/// Gets an user's favorite movies and / or shows.
/// <para>OAuth authorization required.</para>
/// <para>
/// See <a href="https://trakt.docs.apiary.io/#reference/sync/get-personal-recommendations/get-personal-recommendations">"Trakt API Doc - Sync: Personal Recommendations"</a> for more information.
/// See <a href="https://trakt.docs.apiary.io/#reference/sync/get-favorites/get-favorites">"Trakt API Doc - Sync: Get Favorites"</a> for more information.
/// </para>
/// </summary>
/// <param name="recommendationObjectType">Determines, which type of recommendation items should be queried. See also <seealso cref="TraktFavoriteObjectType" />.</param>
/// <param name="favoriteObjectType">Determines, which type of favorite items should be queried. See also <seealso cref="TraktFavoriteObjectType" />.</param>
/// <param name="sortOrder">
/// The recommendations sort order. See also <seealso cref="TraktWatchlistSortOrder" />.
/// The favorites sort order. See also <seealso cref="TraktWatchlistSortOrder" />.
/// Will be ignored, if the given array contains a number higher than 10 or below 1 or if it contains more than ten numbers.
/// Will be ignored, if the given <paramref name="recommendationObjectType" /> is null or unspecified.
/// Will be ignored, if the given <paramref name="favoriteObjectType" /> is null or unspecified.
/// </param>
/// <param name="extendedInfo">
/// The extended info, which determines how much data about the recommendation items should be queried.
/// The extended info, which determines how much data about the favorite items should be queried.
/// See also <seealso cref="TraktExtendedInfo" />.
/// </param>
/// <param name="pagedParameters">Specifies pagination parameters. <see cref="TraktPagedParameters" />.</param>
Expand All @@ -87,13 +87,13 @@ public Task<TraktResponse<ITraktSyncLastActivities>> GetLastActivitiesAsync(Canc
/// </param>
/// <returns>A list of <see cref="ITraktFavorite" /> instances.</returns>
/// <exception cref="TraktException">Thrown, if the request fails.</exception>
public Task<TraktPagedResponse<ITraktFavorite>> GetPersonalRecommendationsAsync(TraktFavoriteObjectType recommendationObjectType = null,
TraktWatchlistSortOrder sortOrder = null, TraktExtendedInfo extendedInfo = null,
TraktPagedParameters pagedParameters = null, CancellationToken cancellationToken = default)
public Task<TraktPagedResponse<ITraktFavorite>> GetFavoritesAsync(TraktFavoriteObjectType favoriteObjectType = null,
TraktWatchlistSortOrder sortOrder = null, TraktExtendedInfo extendedInfo = null,
TraktPagedParameters pagedParameters = null, CancellationToken cancellationToken = default)
{
var request = new SyncPersonalRecommendationsRequest
var request = new SyncFavoritesRequest
{
Type = recommendationObjectType,
Type = favoriteObjectType,
Sort = sortOrder,
ExtendedInfo = extendedInfo,
Page = pagedParameters?.Page,
Expand All @@ -104,31 +104,31 @@ public Task<TraktPagedResponse<ITraktFavorite>> GetPersonalRecommendationsAsync(
}

/// <summary>
/// Reorder all items on a user's personal recommendations.
/// Reorder all user's favorites.
/// <para>OAuth authorization required.</para>
/// <para>
/// See <a href="https://trakt.docs.apiary.io/#reference/sync/reorder-personal-recommendations/reorder-personally-recommended-items">"Trakt API Doc - Sync: Reorder Personal Recommendations"</a> for more information.
/// See <a href="https://trakt.docs.apiary.io/#reference/sync/reorder-favorites/reorder-favorited-items">"Trakt API Doc - Sync: Reorder Favorites"</a> for more information.
/// </para>
/// </summary>
/// <param name="reorderedRecommendedItemRanks">A collection of list ids. Represents the new order of an user's personal recommendations.</param>
/// <param name="reorderedFavoritedItemRanks">A collection of list ids. Represents the new order of an user's favorites.</param>
/// <param name="cancellationToken">
/// Propagates notification that the request should be canceled.<para/>
/// If provided, the exception <see cref="OperationCanceledException" /> should be catched.
/// </param>
/// <returns>An <see cref="ITraktListItemsReorderPostResponse" /> instance containing information about the successfully updated personal recommendations order.</returns>
/// <returns>An <see cref="ITraktListItemsReorderPostResponse" /> instance containing information about the successfully updated favorites order.</returns>
/// <exception cref="TraktException">Thrown, if the request fails.</exception>
/// <exception cref="TraktPostValidationException">Thrown, if validation of post data fails.</exception>
/// <exception cref="TraktRequestValidationException">Thrown, if validation of request data fails.</exception>
public Task<TraktResponse<ITraktListItemsReorderPostResponse>> ReorderRecommendedItemsAsync(IList<uint> reorderedRecommendedItemRanks,
CancellationToken cancellationToken = default)
public Task<TraktResponse<ITraktListItemsReorderPostResponse>> ReorderFavoritedItemsAsync(IList<uint> reorderedFavoritedItemRanks,
CancellationToken cancellationToken = default)
{
var requestHandler = new RequestHandler(Client);

return requestHandler.ExecuteSingleItemRequestAsync(new SyncRecommendedItemsReorderRequest
return requestHandler.ExecuteSingleItemRequestAsync(new SyncFavoritedItemsReorderRequest
{
RequestBody = new TraktListItemsReorderPost
{
Rank = reorderedRecommendedItemRanks
Rank = reorderedFavoritedItemRanks
}
},
cancellationToken);
Expand Down Expand Up @@ -633,67 +633,67 @@ public Task<TraktResponse<ITraktSyncRatingsRemovePostResponse>> RemoveRatingsAsy
}

/// <summary>
/// Adds items to the user's personal recommendations. Accepts movies and shows.
/// Adds items to the user's favorites. Accepts movies and shows.
/// <para>OAuth authorization required.</para>
/// <para>
/// See <a href="https://trakt.docs.apiary.io/#reference/sync/get-personal-recommendations/add-items-to-personal-recommendations">"Trakt API Doc - Sync: Add to Personal Recommendations"</a> for more information.
/// See <a href="https://trakt.docs.apiary.io/#reference/sync/add-to-favorites/add-items-to-favorites">"Trakt API Doc - Sync: Add to Favorites"</a> for more information.
/// </para>
/// <para>
/// It is recommended to use the <see cref="ITraktSyncRecommendationsPostBuilder" /> to create an instance
/// of the required <see cref="ITraktSyncRecommendationsPost" />.
/// See also <seealso cref="TraktPost.NewSyncRecommendationsPost()" />.
/// It is recommended to use the <see cref="ITraktSyncFavoritesPostBuilder" /> to create an instance
/// of the required <see cref="ITraktSyncFavoritesPost" />.
/// See also <seealso cref="TraktPost.NewSyncFavoritesPost()" />.
/// </para>
/// </summary>
/// <param name="recommendationsPost">An <see cref="ITraktSyncRecommendationsPost" /> instance containing all movies and shows, which should be added.</param>
/// <param name="favoritesPost">An <see cref="ITraktSyncFavoritesPost" /> instance containing all movies and shows, which should be added.</param>
/// <param name="cancellationToken">
/// Propagates notification that the request should be canceled.<para/>
/// If provided, the exception <see cref="OperationCanceledException" /> should be catched.
/// </param>
/// <returns>An <see cref="ITraktSyncRecommendationsPostResponse" /> instance, which contains information about which items were added and not found.</returns>
/// <returns>An <see cref="ITraktSyncFavoritesPostResponse" /> instance, which contains information about which items were added and not found.</returns>
/// <exception cref="TraktException">Thrown, if the request fails.</exception>
/// <exception cref="TraktPostValidationException">Thrown, if validation of post data fails.</exception>
/// <exception cref="TraktRequestValidationException">Thrown, if validation of request data fails.</exception>
public Task<TraktResponse<ITraktSyncRecommendationsPostResponse>> AddPersonalRecommendationsAsync(ITraktSyncRecommendationsPost recommendationsPost,
CancellationToken cancellationToken = default)
public Task<TraktResponse<ITraktSyncFavoritesPostResponse>> AddFavoriteItemsAsync(ITraktSyncFavoritesPost favoritesPost,
CancellationToken cancellationToken = default)
{
var requestHandler = new RequestHandler(Client);

return requestHandler.ExecuteSingleItemRequestAsync(new SyncRecommendationsAddRequest
return requestHandler.ExecuteSingleItemRequestAsync(new SyncFavoritesAddRequest
{
RequestBody = recommendationsPost
RequestBody = favoritesPost
},
cancellationToken);
}

/// <summary>
/// Remove items from the user's personal recommendations. Accepts movies and shows.
/// Remove items from the user's favorites. Accepts movies and shows.
/// <para>OAuth authorization required.</para>
/// <para>
/// See <a href="https://trakt.docs.apiary.io/#reference/sync/remove-from-personal-recommendations/remove-items-from-personal-recommendations">"Trakt API Doc - Sync: Remove from Personal Recommendations"</a> for more information.
/// See <a href="https://trakt.docs.apiary.io/#reference/sync/remove-from-favorites/remove-items-from-favorites">"Trakt API Doc - Sync: Remove from Favorites"</a> for more information.
/// </para>
/// <para>
/// It is recommended to use the <see cref="ITraktSyncRecommendationsRemovePostBuilder" /> to create an instance
/// of the required <see cref="ITraktSyncRecommendationsRemovePost" />.
/// See also <seealso cref="TraktPost.NewSyncRecommendationsRemovePost()" />.
/// It is recommended to use the <see cref="ITraktSyncFavoritesRemovePostBuilder" /> to create an instance
/// of the required <see cref="ITraktSyncFavoritesRemovePost" />.
/// See also <seealso cref="TraktPost.NewSyncFavoritesRemovePost()" />.
/// </para>
/// </summary>
/// <param name="recommendationsRemovePost">An <see cref="ITraktSyncRecommendationsRemovePost" /> instance containing all movies and shows, which should be removed.</param>
/// <param name="favoritesRemovePost">An <see cref="ITraktSyncFavoritesRemovePost" /> instance containing all movies and shows, which should be removed.</param>
/// <param name="cancellationToken">
/// Propagates notification that the request should be canceled.<para/>
/// If provided, the exception <see cref="OperationCanceledException" /> should be catched.
/// </param>
/// <returns>An <see cref="ITraktSyncRecommendationsRemovePostResponse" /> instance, which contains information about which items were removed and not found.</returns>
/// <returns>An <see cref="ITraktSyncFavoritesRemovePostResponse" /> instance, which contains information about which items were removed and not found.</returns>
/// <exception cref="TraktException">Thrown, if the request fails.</exception>
/// <exception cref="TraktPostValidationException">Thrown, if validation of post data fails.</exception>
/// <exception cref="TraktRequestValidationException">Thrown, if validation of request data fails.</exception>
public Task<TraktResponse<ITraktSyncRecommendationsRemovePostResponse>> RemovePersonalRecommendationsAsync(ITraktSyncRecommendationsRemovePost recommendationsRemovePost,
CancellationToken cancellationToken = default)
public Task<TraktResponse<ITraktSyncFavoritesRemovePostResponse>> RemoveFavoriteItemsAsync(ITraktSyncFavoritesRemovePost favoritesRemovePost,
CancellationToken cancellationToken = default)
{
var requestHandler = new RequestHandler(Client);

return requestHandler.ExecuteSingleItemRequestAsync(new SyncRecommendationsRemoveRequest
return requestHandler.ExecuteSingleItemRequestAsync(new SyncFavoritesRemoveRequest
{
RequestBody = recommendationsRemovePost
RequestBody = favoritesRemovePost
},
cancellationToken);
}
Expand Down
32 changes: 16 additions & 16 deletions Source/Lib/Trakt.NET/Objects/Json/JsonFactoryContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
using Post.Syncs.Collection.Json.Factories;
using Post.Syncs.Collection.Responses;
using Post.Syncs.Collection.Responses.Json.Factories;
using Post.Syncs.Favorites;
using Post.Syncs.Favorites.Json.Factories;
using Post.Syncs.Favorites.Responses;
using Post.Syncs.Favorites.Responses.Json.Factories;
using Post.Syncs.History;
using Post.Syncs.History.Json.Factories;
using Post.Syncs.History.Responses;
Expand All @@ -72,10 +76,6 @@
using Post.Syncs.Ratings.Json.Factories;
using Post.Syncs.Ratings.Responses;
using Post.Syncs.Ratings.Responses.Json.Factories;
using Post.Syncs.Recommendations;
using Post.Syncs.Recommendations.Json.Factories;
using Post.Syncs.Recommendations.Responses;
using Post.Syncs.Recommendations.Responses.Json.Factories;
using Post.Syncs.Responses;
using Post.Syncs.Responses.Json.Factories;
using Post.Syncs.Watchlist;
Expand Down Expand Up @@ -327,6 +327,18 @@ static JsonFactoryContainer()
s_jsonIOFactories.Add(typeof(ITraktSyncCollectionPostResponse), new SyncCollectionPostResponseJsonIOFactory());
s_jsonIOFactories.Add(typeof(ITraktSyncCollectionRemovePostResponse), new SyncCollectionRemovePostResponseJsonIOFactory());

// sync favorites post objects
s_jsonIOFactories.Add(typeof(ITraktSyncFavoritesPost), new SyncFavoritesPostJsonIOFactory());
s_jsonIOFactories.Add(typeof(ITraktSyncFavoritesPostMovie), new SyncFavoritesPostMovieJsonIOFactory());
s_jsonIOFactories.Add(typeof(ITraktSyncFavoritesPostShow), new SyncFavoritesPostShowJsonIOFactory());
s_jsonIOFactories.Add(typeof(ITraktSyncFavoritesRemovePost), new SyncFavoritesRemovePostJsonIOFactory());

// sync favorites post response objects
s_jsonIOFactories.Add(typeof(ITraktSyncFavoritesPostResponse), new SyncFavoritesPostResponseJsonIOFactory());
s_jsonIOFactories.Add(typeof(ITraktSyncFavoritesRemovePostResponse), new SyncFavoritesRemovePostResponseJsonIOFactory());
s_jsonIOFactories.Add(typeof(ITraktSyncFavoritesPostResponseGroup), new SyncFavoritesPostResponseGroupJsonIOFactory());
s_jsonIOFactories.Add(typeof(ITraktSyncFavoritesPostResponseNotFoundGroup), new SyncFavoritesPostResponseNotFoundGroupJsonIOFactory());

// sync history post objects
s_jsonIOFactories.Add(typeof(ITraktSyncHistoryPost), new SyncHistoryPostJsonIOFactory());
s_jsonIOFactories.Add(typeof(ITraktSyncHistoryPostEpisode), new SyncHistoryPostEpisodeJsonIOFactory());
Expand Down Expand Up @@ -368,18 +380,6 @@ static JsonFactoryContainer()
s_jsonIOFactories.Add(typeof(ITraktSyncRatingsPostResponseNotFoundShow), new SyncRatingsPostResponseNotFoundShowJsonIOFactory());
s_jsonIOFactories.Add(typeof(ITraktSyncRatingsRemovePostResponse), new SyncRatingsRemovePostResponseJsonIOFactory());

// sync recommendations post objects
s_jsonIOFactories.Add(typeof(ITraktSyncRecommendationsPost), new SyncRecommendationsPostJsonIOFactory());
s_jsonIOFactories.Add(typeof(ITraktSyncRecommendationsPostMovie), new SyncRecommendationsPostMovieJsonIOFactory());
s_jsonIOFactories.Add(typeof(ITraktSyncRecommendationsPostShow), new SyncRecommendationsPostShowJsonIOFactory());
s_jsonIOFactories.Add(typeof(ITraktSyncRecommendationsRemovePost), new SyncRecommendationsRemovePostJsonIOFactory());

// sync recommendations post response objects
s_jsonIOFactories.Add(typeof(ITraktSyncRecommendationsPostResponse), new SyncRecommendationsPostResponseJsonIOFactory());
s_jsonIOFactories.Add(typeof(ITraktSyncRecommendationsRemovePostResponse), new SyncRecommendationsRemovePostResponseJsonIOFactory());
s_jsonIOFactories.Add(typeof(ITraktSyncRecommendationsPostResponseGroup), new SyncRecommendationsPostResponseGroupJsonIOFactory());
s_jsonIOFactories.Add(typeof(ITraktSyncRecommendationsPostResponseNotFoundGroup), new SyncRecommendationsPostResponseNotFoundGroupJsonIOFactory());

// sync playback objects
s_jsonIOFactories.Add(typeof(ITraktSyncPlaybackProgressItem), new SyncPlaybackProgressItemJsonIOFactory());

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace TraktNet.Objects.Post.Syncs.Favorites
{
using Requests.Interfaces;
using System.Collections.Generic;

/// <summary>A Trakt favorites post, containing all movies and shows, which should be favorited by an user.</summary>
public interface ITraktSyncFavoritesPost : IRequestBody
{
/// <summary>
/// An optional list of <see cref="ITraktSyncFavoritesPostMovie" />s.
/// <para>Each <see cref="ITraktSyncFavoritesPostMovie" /> must have at least a valid Trakt id.</para>
/// </summary>
IList<ITraktSyncFavoritesPostMovie> Movies { get; set; }

/// <summary>
/// An optional list of <see cref="ITraktSyncFavoritesPostShow" />s.
/// <para>Each <see cref="ITraktSyncFavoritesPostShow" /> must have at least a valid Trakt id.</para>
/// </summary>
IList<ITraktSyncFavoritesPostShow> Shows { get; set; }
}
}
Loading

0 comments on commit 1f8d158

Please sign in to comment.