Exemplo n.º 1
0
        /// <summary>
        /// Stops watching a <see cref="ITraktEpisode" /> in a media center. Use this method, if the given episode has no valid ids.
        /// <para>OAuth authorization required.</para>
        /// <para>
        /// See <a href="http://docs.trakt.apiary.io/#reference/scrobble/start-watching-in-a-media-center">"Trakt API Doc - Scrobble: Start"</a> for more information.
        /// </para>
        /// </summary>
        /// <param name="absoluteEpisodeNumber">The absolute number of the episode, which will be scrobbled.</param>
        /// <param name="show">The <see cref="ITraktShow" />, which will be used to scrobble the given episode.</param>
        /// <param name="progress">The watching progress. Should be a value between 0 and 100.</param>
        /// <param name="appVersion">Optional application version for the scrobble.</param>
        /// <param name="appBuildDate">Optional application build date for the scrobble. Will be converted to the Trakt date-format.</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="ITraktEpisodeScrobblePostResponse" /> instance, containing the successfully scrobbled episode's data.</returns>
        /// <exception cref="TraktException">Thrown, if the request fails.</exception>
        /// <exception cref="ArgumentNullException">Thrown, if the given episode is null or if the given episode's ids are null and the given show is null.</exception>
        /// <exception cref="ArgumentException">Thrown, if given show's title is null or empty.</exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Thrown, if the given episode's season number is below zero or the given episode's number is below one.
        /// Thrown, if the given progress value is not between 0 and 100.
        /// </exception>
        public Task <TraktResponse <ITraktEpisodeScrobblePostResponse> > StopEpisodeWithShowAsync(int absoluteEpisodeNumber, ITraktShow show, float progress,
                                                                                                  string appVersion = null, DateTime?appBuildDate = null,
                                                                                                  CancellationToken cancellationToken = default)
        {
            var requestHandler = new RequestHandler(Client);
            ITraktEpisodeScrobblePost requestBody = CreateEpisodeScrobblePost(absoluteEpisodeNumber, progress, show, appVersion, appBuildDate);

            return(requestHandler.ExecuteSingleItemRequestAsync(CreateScrobbleStopRequest <ITraktEpisodeScrobblePostResponse, ITraktEpisodeScrobblePost>(requestBody), cancellationToken));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Pauses watching a <see cref="ITraktEpisode" /> in a media center.
        /// <para>OAuth authorization required.</para>
        /// <para>
        /// See <a href="http://docs.trakt.apiary.io/#reference/scrobble/start-watching-in-a-media-center">"Trakt API Doc - Scrobble: Start"</a> for more information.
        /// </para>
        /// </summary>
        /// <param name="episode">The <see cref="ITraktEpisode" />, which will be scrobbled.</param>
        /// <param name="progress">The watching progress. Should be a value between 0 and 100.</param>
        /// <param name="appVersion">Optional application version for the scrobble.</param>
        /// <param name="appBuildDate">Optional application build date for the scrobble. Will be converted to the Trakt date-format.</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="ITraktEpisodeScrobblePostResponse" /> instance, containing the successfully scrobbled episode's data.</returns>
        /// <exception cref="TraktException">Thrown, if the request fails.</exception>
        /// <exception cref="ArgumentNullException">
        /// Thrown, if the given episode is null or if the given episode's ids are null.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Thrown, if the given episode's season number is below zero or the given episode's number is below one.
        /// Thrown, if the given progress value is not between 0 and 100.
        /// </exception>
        public Task <TraktResponse <ITraktEpisodeScrobblePostResponse> > PauseEpisodeAsync(ITraktEpisode episode, float progress,
                                                                                           string appVersion = null, DateTime?appBuildDate = null,
                                                                                           CancellationToken cancellationToken = default)
        {
            var requestHandler = new RequestHandler(Client);
            ITraktEpisodeScrobblePost requestBody = CreateEpisodeScrobblePost(episode, progress, null, appVersion, appBuildDate);

            return(requestHandler.ExecuteSingleItemRequestAsync(CreateScrobblePauseRequest <ITraktEpisodeScrobblePostResponse, ITraktEpisodeScrobblePost>(requestBody), cancellationToken));
        }