StarGist() public static method

Returns the Uri to star a given gist.
public static StarGist ( string id ) : Uri
id string The id of the gist
return Uri
Esempio n. 1
0
        public async Task <bool> IsStarred(string id)
        {
            Ensure.ArgumentNotNullOrEmptyString(id, nameof(id));

            try
            {
                var response = await Connection.Get <object>(ApiUrls.StarGist(id), null, null).ConfigureAwait(false);

                return(response.HttpResponse.IsTrue());
            }
            catch (NotFoundException)
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Checks if the gist is starred
        /// </summary>
        /// <remarks>
        /// http://developer.github.com/v3/gists/#check-if-a-gist-is-starred
        /// </remarks>
        /// <param name="id">The id of the gist</param>
        public async Task <bool> IsStarred(string id)
        {
            Ensure.ArgumentNotNullOrEmptyString(id, "id");

            try
            {
                var response = await Connection.GetAsync <object>(ApiUrls.StarGist(id), null, null)
                               .ConfigureAwait(false);

                if (response.StatusCode != HttpStatusCode.NotFound && response.StatusCode != HttpStatusCode.NoContent)
                {
                    throw new ApiException("Invalid Status Code returned. Expected a 204 or a 404", response.StatusCode);
                }
                return(response.StatusCode == HttpStatusCode.NoContent);
            }
            catch (NotFoundException)
            {
                return(false);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Unstars a gist
 /// </summary>
 /// <remarks>
 /// http://developer.github.com/v3/gists/#unstar-a-gist
 /// </remarks>
 /// <param name="id">The id of the gist</param>
 public Task Unstar(string id)
 {
     return(ApiConnection.Delete(ApiUrls.StarGist(id)));
 }
Esempio n. 4
0
 /// <summary>
 /// Stars a gist
 /// </summary>
 /// <remarks>
 /// http://developer.github.com/v3/gists/#star-a-gist
 /// </remarks>
 /// <param name="id">The id of the gist</param>
 public Task Star(string id)
 {
     return(ApiConnection.Put(ApiUrls.StarGist(id)));
 }
Esempio n. 5
0
        public Task Unstar(string id)
        {
            Ensure.ArgumentNotNullOrEmptyString(id, nameof(id));

            return(ApiConnection.Delete(ApiUrls.StarGist(id)));
        }
Esempio n. 6
0
        /// <summary>
        /// Stars a gist
        /// </summary>
        /// <remarks>
        /// http://developer.github.com/v3/gists/#star-a-gist
        /// </remarks>
        /// <param name="id">The id of the gist</param>
        public Task Star(string id)
        {
            Ensure.ArgumentNotNullOrEmptyString(id, "id");

            return(ApiConnection.Put(ApiUrls.StarGist(id)));
        }