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

DeleteAlbumAsync() public method

Delete an Album with a given id. 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 DeleteAlbumAsync ( string albumId, string username = "me" ) : Task
albumId string The album id.
username string The user account. Default: me
return Task
        public async Task<bool> DeleteAlbumAsync(string albumId, string username = "me")
        {
            if (string.IsNullOrWhiteSpace(albumId))
                throw new ArgumentNullException(nameof(albumId));

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

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

            var url = $"account/{username}/album/{albumId}";

            using (var request = AlbumRequestBuilder.CreateRequest(HttpMethod.Delete, url))
            {
                var deleted = await SendRequestAsync<bool>(request).ConfigureAwait(false);
                return deleted;
            }
        }

Usage Example

コード例 #1
0
 public async Task DeleteAlbumAsync_WithUsernameNull_ThrowsArgumentNullException()
 {
     var fakeOAuth2TokenHandler = new FakeOAuth2TokenHandler();
     var client = new ImgurClient("123", "1234", fakeOAuth2TokenHandler.GetOAuth2TokenCodeResponse());
     var endpoint = new AccountEndpoint(client);
     await endpoint.DeleteAlbumAsync("yMgB7", null);
 }
All Usage Examples Of Imgur.API.Endpoints.Impl.AccountEndpoint::DeleteAlbumAsync