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

GetCommentAsync() public method

Return information about a specific comment.
/// 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 GetCommentAsync ( int commentId, string username = "me" ) : Task
commentId int The comment id.
username string The user account. Default: me
return Task
        public async Task<IComment> GetCommentAsync(int commentId, 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}/comment/{commentId}";

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

Usage Example

コード例 #1
0
        public async Task GetCommentAsync_AreEqual()
        {
            var client = new ImgurClient(ClientId, ClientSecret);
            var endpoint = new AccountEndpoint(client);

            var comment = await endpoint.GetCommentAsync("300731088", "sarah");

            Assert.IsNotNull(comment);
        }
All Usage Examples Of Imgur.API.Endpoints.Impl.AccountEndpoint::GetCommentAsync