IsFollowing() public static method

Creates the relative Uri for checking is the current user is following another user
public static IsFollowing ( string following ) : Uri
following string name of the user followed
return System.Uri
Esempio n. 1
0
        public async Task <bool> IsFollowingForCurrent(string following)
        {
            Ensure.ArgumentNotNullOrEmptyString(following, nameof(following));

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

                return(response.HttpResponse.IsTrue());
            }
            catch (NotFoundException)
            {
                return(false);
            }
        }
Esempio n. 2
0
        public async Task <bool> Follow(string login)
        {
            Ensure.ArgumentNotNullOrEmptyString(login, nameof(login));

            try
            {
                var requestData = new { };
                var response    = await Connection.Put <object>(ApiUrls.IsFollowing(login), requestData).ConfigureAwait(false);

                if (response.HttpResponse.StatusCode != HttpStatusCode.NoContent)
                {
                    throw new ApiException("Invalid Status Code returned. Expected a 204", response.HttpResponse.StatusCode);
                }
                return(response.HttpResponse.StatusCode == HttpStatusCode.NoContent);
            }
            catch (NotFoundException)
            {
                return(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Check if the authenticated user follows another user
        /// </summary>
        /// <param name="following">The login name of the other user</param>
        /// <remarks>
        /// See the <a href="http://developer.github.com/v3/users/followers/#check-if-you-are-following-a-user">API documentation</a> for more information.
        /// </remarks>
        /// <returns>A <c>bool</c> representing the success of the operation.</returns>
        public async Task <bool> IsFollowingForCurrent(string following)
        {
            Ensure.ArgumentNotNullOrEmptyString(following, "following");

            try
            {
                var response = await Connection.Get <object>(ApiUrls.IsFollowing(following), 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. 4
0
        public Task Unfollow(string login)
        {
            Ensure.ArgumentNotNullOrEmptyString(login, nameof(login));

            return(ApiConnection.Delete(ApiUrls.IsFollowing(login)));
        }