Imgur.API.Endpoints.Impl.AccountEndpoint.GetCommentCountAsync C# (CSharp) Method

GetCommentCountAsync() public method

Return a count of all of the comments associated with the account.
/// Thrown when a null reference is passed to a method that does not accept it as a /// valid argument. /// Thrown when an error is found in a response from an Imgur endpoint. Thrown when an error is found in a response from a Mashape endpoint.
public GetCommentCountAsync ( string username = "me" ) : Task
username string The user account. Default: me
return Task
        public async Task<int> GetCommentCountAsync(string username = "me")
        {
            if (string.IsNullOrWhiteSpace(username))
                throw new ArgumentNullException(nameof(username));

            if (username.Equals("me", StringComparison.OrdinalIgnoreCase)
                && ApiClient.OAuth2Token == null)
                throw new ArgumentNullException(nameof(ApiClient.OAuth2Token), OAuth2RequiredExceptionMessage);

            var url = $"account/{username}/comments/count";

            using (var request = CommentRequestBuilder.CreateRequest(HttpMethod.Get, url))
            {
                var count = await SendRequestAsync<int>(request).ConfigureAwait(false);
                return count;
            }
        }

Usage Example

Esempio n. 1
0
        public async Task GetCommentCountAsync_AreEqual()
        {
            var client = new ImgurClient(ClientId, ClientSecret);
            var endpoint = new AccountEndpoint(client);

            var commentCount = await endpoint.GetCommentCountAsync("sarah");

            Assert.IsTrue(commentCount > 100);
        }
All Usage Examples Of Imgur.API.Endpoints.Impl.AccountEndpoint::GetCommentCountAsync