コード例 #1
0
 private ITraktUserHiddenItemsPostSeason CreateUserHiddenItemsPostSeason(ITraktSeason season)
 {
     return(new TraktUserHiddenItemsPostSeason
     {
         Ids = season.Ids
     });
 }
コード例 #2
0
        public ITraktUserHiddenItemsPostBuilder WithSeason(ITraktSeason season)
        {
            if (season == null)
            {
                throw new ArgumentNullException(nameof(season));
            }

            _seasons.Add(season);
            return(this);
        }
コード例 #3
0
        private void ValidateSeason(ITraktSeason season)
        {
            if (season.Ids == null)
            {
                throw new ArgumentNullException(nameof(season.Ids));
            }

            if (!season.Ids.HasAnyId)
            {
                throw new ArgumentException("no season ids set or valid", nameof(season.Ids));
            }
        }
コード例 #4
0
        private void ValidateSeason(ITraktSeason season)
        {
            if (season == null)
            {
                throw new ArgumentNullException(nameof(season), "season must not be null");
            }

            if (season.Ids == null)
            {
                throw new ArgumentNullException(nameof(season.Ids), "season ids must not be null");
            }

            if (!season.Ids.HasAnyId)
            {
                throw new ArgumentException("season ids have no valid id", nameof(season.Ids));
            }
        }
コード例 #5
0
        public TraktUserHiddenItemsPostBuilder AddSeason(ITraktSeason season)
        {
            ValidateSeason(season);
            EnsureSeasonsListExists();

            var existingSeason = _hiddenItemsPost.Movies.FirstOrDefault(s => s.Ids == season.Ids);

            if (existingSeason != null)
            {
                return(this);
            }

            (_hiddenItemsPost.Seasons as List <TraktUserHiddenItemsPostSeason>)?.Add(
                new TraktUserHiddenItemsPostSeason
            {
                Ids = season.Ids
            });

            return(this);
        }
コード例 #6
0
        /// <summary>
        /// Posts a comment for the given <see cref="ITraktSeason" />.
        /// <para>OAuth authorization required.</para>
        /// <para>
        /// See <a href="http://docs.trakt.apiary.io/#reference/comments/comments/post-a-comment">"Trakt API Doc - Comments: Comments"</a> for more information.
        /// </para>
        /// </summary>
        /// <param name="season">The <see cref="ITraktSeason" />, for which the comment should be posted.</param>
        /// <param name="comment">The comment's content for the given season. Should be at least five words long.</param>
        /// <param name="containsSpoiler">Determines, if the <paramref name="comment" /> contains any spoilers.</param>
        /// <param name="sharing"><see cref="ITraktSharing" /> instance, containing sharing information for the comment.</param>
        /// <param name="cancellationToken"></param>
        /// <returns>An <see cref="ITraktCommentPostResponse" /> instance, containing the successfully posted comment's data.</returns>
        /// <exception cref="TraktException">Thrown, if the request fails.</exception>
        /// <exception cref="ArgumentException">
        /// Thrown, if the given season has no valid ids. See also <seealso cref="ITraktSeasonIds" />.
        /// Thrown, if the given comment is null or empty.
        /// </exception>
        /// <exception cref="ArgumentNullException">Thrown, if the given season is null or its ids are null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown, if the given comment's word count is below five.</exception>
        public Task <TraktResponse <ITraktCommentPostResponse> > PostSeasonCommentAsync(ITraktSeason season, string comment,
                                                                                        bool?containsSpoiler = null, ITraktSharing sharing = null,
                                                                                        CancellationToken cancellationToken = default)
        {
            ValidateSeason(season);
            ValidateComment(comment);

            var requestHandler = new RequestHandler(Client);

            return(requestHandler.ExecuteSingleItemRequestAsync(new CommentPostRequest <ITraktSeasonCommentPost>
            {
                RequestBody = new TraktSeasonCommentPost
                {
                    Season = new TraktSeason
                    {
                        Ids = season.Ids
                    },
                    Comment = comment,
                    Spoiler = containsSpoiler,
                    Sharing = sharing
                }
            },
                                                                cancellationToken));
        }