/// <summary> /// Change the state of a specific movie on the users watchlist. Either add the movie to the list or remove it, depending on the specified boolean value. /// </summary> /// <param name="mediaType">The type of media to influence</param> /// <param name="mediaId">The id of the movie/tv show to influence</param> /// <param name="isOnWatchlist">True if you want the specified movie to be part of the watchlist, false if not</param> /// <returns>True if the the movie's status on the watchlist was successfully updated, false if not</returns> /// <remarks>Requires a valid user session</remarks> /// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception> public async Task <bool> AccountChangeWatchlistStatusAsync(MediaType mediaType, int mediaId, bool isOnWatchlist) { RequireSessionId(SessionType.UserSession); RestRequest request = _client.Create("account/{accountId}/watchlist"); request.AddUrlSegment("accountId", ActiveAccount.Id.ToString(CultureInfo.InvariantCulture)); request.SetBody(new { media_type = mediaType.GetDescription(), media_id = mediaId, watchlist = isOnWatchlist }); AddSessionId(request, SessionType.UserSession); PostReply response = await request.ExecutePost <PostReply>().ConfigureAwait(false); // status code 1 = "Success" // status code 13 = "The item/record was deleted successfully" - When removing an item from the watchlist, no matter if it exists or not // status code 12 = "The item/record was updated successfully" - Used when an item is already on the watchlist and trying to add it again return(response.StatusCode == 1 || response.StatusCode == 12 || response.StatusCode == 13); }
/// <summary> /// Change the favorite status of a specific movie. Either make the movie a favorite or remove that status depending on the supplied boolean value. /// </summary> /// <param name="mediaType">The type of media to influence</param> /// <param name="mediaId">The id of the movie/tv show to influence</param> /// <param name="isFavorite">True if you want the specified movie to be marked as favorite, false if not</param> /// <returns>True if the the movie's favorite status was successfully updated, false if not</returns> /// <remarks>Requires a valid user session</remarks> /// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception> public async Task <bool> AccountChangeFavoriteStatusAsync(MediaType mediaType, int mediaId, bool isFavorite) { RequireSessionId(SessionType.UserSession); RestRequest request = _client.Create("account/{accountId}/favorite"); request.AddUrlSegment("accountId", ActiveAccount.Id.ToString(CultureInfo.InvariantCulture)); request.SetBody(new { media_type = mediaType.GetDescription(), media_id = mediaId, favorite = isFavorite }); AddSessionId(request, SessionType.UserSession); PostReply response = await request.ExecutePost <PostReply>().ConfigureAwait(false); // status code 1 = "Success" - Returned when adding a movie as favorite for the first time // status code 13 = "The item/record was deleted successfully" - When removing an item as favorite, no matter if it exists or not // status code 12 = "The item/record was updated successfully" - Used when an item is already marked as favorite and trying to do so doing again return(response.StatusCode == 1 || response.StatusCode == 12 || response.StatusCode == 13); }
/// <summary> /// Change the favorite status of a specific movie. Either make the movie a favorite or remove that status depending on the supplied boolean value. /// </summary> /// <param name="mediaType">The type of media to influence</param> /// <param name="mediaId">The id of the movie/tv show to influence</param> /// <param name="isFavorite">True if you want the specified movie to be marked as favorite, false if not</param> /// <returns>True if the the movie's favorite status was successfully updated, false if not</returns> /// <remarks>Requires a valid user session</remarks> /// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception> public bool AccountChangeFavoriteStatus(MediaType mediaType, int mediaId, bool isFavorite) { RequireSessionId(SessionType.UserSession); RestRequest request = new RestRequest("account/{accountId}/favorite") { RequestFormat = DataFormat.Json }; request.AddUrlSegment("accountId", ActiveAccount.Id.ToString(CultureInfo.InvariantCulture)); request.AddParameter("session_id", SessionId, ParameterType.QueryString); request.AddBody(new { media_type = mediaType.GetDescription(), media_id = mediaId, favorite = isFavorite }); IRestResponse <PostReply> response = _client.Post <PostReply>(request); // status code 1 = "Success" - Returned when adding a movie as favorite for the first time // status code 13 = "The item/record was deleted successfully" - When removing an item as favorite, no matter if it exists or not // status code 12 = "The item/record was updated successfully" - Used when an item is already marked as favorite and trying to do so doing again return(response.Data != null && (response.Data.StatusCode == 1 || response.Data.StatusCode == 12 || response.Data.StatusCode == 13)); }
/// <summary> /// Change the state of a specific movie on the users watchlist. Either add the movie to the list or remove it, depending on the specified boolean value. /// </summary> /// <param name="mediaType">The type of media to influence</param> /// <param name="mediaId">The id of the movie/tv show to influence</param> /// <param name="isOnWatchlist">True if you want the specified movie to be part of the watchlist, false if not</param> /// <returns>True if the the movie's status on the watchlist was successfully updated, false if not</returns> /// <remarks>Requires a valid user session</remarks> /// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception> public bool AccountChangeWatchlistStatus(MediaType mediaType, int mediaId, bool isOnWatchlist) { RequireSessionId(SessionType.UserSession); RestRequest request = new RestRequest("account/{accountId}/watchlist") { RequestFormat = DataFormat.Json }; request.AddUrlSegment("accountId", ActiveAccount.Id.ToString(CultureInfo.InvariantCulture)); request.AddParameter("session_id", SessionId, ParameterType.QueryString); request.AddBody(new { media_type = mediaType.GetDescription(), media_id = mediaId, watchlist = isOnWatchlist }); IRestResponse <PostReply> response = _client.Post <PostReply>(request); // status code 1 = "Success" // status code 13 = "The item/record was deleted successfully" - When removing an item from the watchlist, no matter if it exists or not // status code 12 = "The item/record was updated successfully" - Used when an item is already on the watchlist and trying to add it again return(response.Data != null && (response.Data.StatusCode == 1 || response.Data.StatusCode == 12 || response.Data.StatusCode == 13)); }
/// <summary> /// Set media type /// </summary> /// <param name="mediaType">Request's media type</param> /// <returns></returns> /// <exception cref="ArgumentNullException"></exception> public RequestClient SetMediaType(MediaTypes mediaType) { if (Enum.IsDefined(typeof(MediaTypes), mediaType) == false) { throw new ArgumentException($"{nameof(mediaType)} is invalid."); } Client.DefaultRequestHeaders.Accept.Remove(new MediaTypeWithQualityHeaderValue(MediaType.GetDescription())); MediaType = mediaType; Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(MediaType.GetDescription())); SetMediaTypeFormatter(MediaType); return(this); }