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

GetCommentIdsAsync() public method

Return a list of all of the comment IDs.
/// 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 GetCommentIdsAsync ( string username = "me", CommentSortOrder sort = CommentSortOrder.Newest, int page = null ) : Task>
username string The user account. Default: me
sort CommentSortOrder The order that the comments should be sorted by. Default: Newest
page int Allows you to set the page number so you don't have to retrieve all the data at once. Default: null
return Task>
        public async Task<IEnumerable<int>> GetCommentIdsAsync(string username = "me",
            CommentSortOrder? sort = CommentSortOrder.Newest, int? page = null)
        {
            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);

            sort = sort ?? CommentSortOrder.Newest;

            var sortValue = $"{sort}".ToLower();
            var url = $"account/{username}/comments/ids/{sortValue}/{page}";

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

Usage Example

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

            var comments = await endpoint.GetCommentIdsAsync("sarah");

            Assert.AreEqual(50, comments.Count());
        }
All Usage Examples Of Imgur.API.Endpoints.Impl.AccountEndpoint::GetCommentIdsAsync