Imgur.API.Endpoints.Impl.CommentEndpoint.CreateReplyAsync C# (CSharp) Method

CreateReplyAsync() public method

Create a reply for the given comment, returns the ID of the comment. OAuth authentication required.
/// 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 CreateReplyAsync ( string comment, string galleryItemId, string parentId ) : Task
comment string The comment text, this is what will be displayed.
galleryItemId string The ID of the item in the gallery that you wish to comment on.
parentId string The comment id that you are replying to.
return Task
        public async Task<int> CreateReplyAsync(string comment, string galleryItemId, string parentId)
        {
            if (string.IsNullOrWhiteSpace(comment))
                throw new ArgumentNullException(nameof(comment));

            if (string.IsNullOrWhiteSpace(galleryItemId))
                throw new ArgumentNullException(nameof(galleryItemId));

            if (string.IsNullOrWhiteSpace(parentId))
                throw new ArgumentNullException(nameof(parentId));

            if (ApiClient.OAuth2Token == null)
                throw new ArgumentNullException(nameof(ApiClient.OAuth2Token), OAuth2RequiredExceptionMessage);

            var url = $"comment/{parentId}";

            using (var request = RequestBuilder.CreateReplyRequest(url, comment, galleryItemId))
            {
                var returnComment = await SendRequestAsync<Comment>(request).ConfigureAwait(false);
                return returnComment.Id;
            }
        }

Usage Example

コード例 #1
0
        public async Task CreateReplyAsync_WithCommentIdNull_ThrowsArgumentNullException()
        {
            var client = new ImgurClient("123", "1234", MockOAuth2Token);
            var endpoint = new CommentEndpoint(client);

            var exception =
                await
                    Record.ExceptionAsync(
                        async () => await endpoint.CreateReplyAsync("Hello World!", "xyz", null).ConfigureAwait(false))
                        .ConfigureAwait(false);
            Assert.NotNull(exception);
            Assert.IsType<ArgumentNullException>(exception);
        }
All Usage Examples Of Imgur.API.Endpoints.Impl.CommentEndpoint::CreateReplyAsync