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

GetAlbumCountAsync() public method

Return a list of all of the album 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 GetAlbumCountAsync ( string username = "me" ) : Task
username string The user account. Default: me
return Task
        public async Task<int> GetAlbumCountAsync(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}/albums/count";

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

Usage Example

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

            var albums = await endpoint.GetAlbumCountAsync("sarah");

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