Watched() публичный статический Метод

Returns the Uri that lists the watched repositories for the authenticated user.
public static Watched ( ) : Uri
Результат Uri
Пример #1
0
        /// <summary>
        /// Watches a repository for the authenticated user.
        /// </summary>
        /// <param name="owner">The owner of the repository to star</param>
        /// <param name="name">The name of the repository to star</param>
        /// <param name="newSubscription">A <see cref="NewSubscription"/> instance describing the new subscription to create</param>
        /// <returns>A <c>bool</c> representing the success of watching</returns>
        public Task <Subscription> WatchRepo(string owner, string name, NewSubscription newSubscription)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNull(newSubscription, "newSubscription");

            return(ApiConnection.Put <Subscription>(ApiUrls.Watched(owner, name), newSubscription));
        }
Пример #2
0
        /// <summary>
        /// Unwatches a repository for the authenticated user.
        /// </summary>
        /// <param name="repositoryId">The Id of the repository</param>
        public async Task <bool> UnwatchRepo(long repositoryId)
        {
            try
            {
                var endpoint   = ApiUrls.Watched(repositoryId);
                var statusCode = await Connection.Delete(endpoint).ConfigureAwait(false);

                return(statusCode == HttpStatusCode.NoContent);
            }
            catch (NotFoundException)
            {
                return(false);
            }
        }
Пример #3
0
        /// <summary>
        /// Check if a repository is watched by the current authenticated user.
        /// </summary>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
        public async Task <bool> CheckWatched(long repositoryId)
        {
            try
            {
                var endpoint     = ApiUrls.Watched(repositoryId);
                var subscription = await ApiConnection.Get <Subscription>(endpoint).ConfigureAwait(false);

                return(subscription != null);
            }
            catch (NotFoundException)
            {
                return(false);
            }
        }
Пример #4
0
        /// <summary>
        /// Check if a repository is watched by the current authenticated user.
        /// </summary>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
        /// <returns>A <c>bool</c> representing the success of the operation</returns>
        public async Task <bool> CheckWatched(string owner, string name)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");

            try
            {
                var subscription = await ApiConnection.Get <Subscription>(ApiUrls.Watched(owner, name))
                                   .ConfigureAwait(false);

                return(subscription != null);
            }
            catch (NotFoundException)
            {
                return(false);
            }
        }
Пример #5
0
        /// <summary>
        /// Unwatches a repository for the authenticated user.
        /// </summary>
        /// <param name="owner">The owner of the repository to unstar</param>
        /// <param name="name">The name of the repository to unstar</param>
        /// <returns>A <c>bool</c> representing the success of the operation</returns>
        public async Task <bool> UnwatchRepo(string owner, string name)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");

            try
            {
                var statusCode = await Connection.DeleteAsync(ApiUrls.Watched(owner, name))
                                 .ConfigureAwait(false);

                return(statusCode == HttpStatusCode.NoContent);
            }
            catch (NotFoundException)
            {
                return(false);
            }
        }
Пример #6
0
 /// <summary>
 /// Retrieves all of the watched <see cref="Repository"/>(ies) for the current user.
 /// </summary>
 /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
 /// <returns>
 /// A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>(ies) watched by the current authenticated user.
 /// </returns>
 public Task <IReadOnlyList <Repository> > GetAllForCurrent()
 {
     return(ApiConnection.GetAll <Repository>(ApiUrls.Watched()));
 }
Пример #7
0
        /// <summary>
        /// Retrieves all of the watched <see cref="Repository"/>(ies) for the current user.
        /// </summary>
        /// <param name="options">Options for changing API's response.</param>
        /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
        /// <returns>
        /// A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>(ies) watched by the current authenticated user.
        /// </returns>
        public Task <IReadOnlyList <Repository> > GetAllForCurrent(ApiOptions options)
        {
            Ensure.ArgumentNotNull(options, nameof(options));

            return(ApiConnection.GetAll <Repository>(ApiUrls.Watched(), options));
        }
Пример #8
0
        /// <summary>
        /// Watches a repository for the authenticated user.
        /// </summary>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="newSubscription">A <see cref="NewSubscription"/> instance describing the new subscription to create</param>
        public Task <Subscription> WatchRepo(long repositoryId, NewSubscription newSubscription)
        {
            Ensure.ArgumentNotNull(newSubscription, nameof(newSubscription));

            return(ApiConnection.Put <Subscription>(ApiUrls.Watched(repositoryId), newSubscription));
        }