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

DeleteImageAsync() public method

Deletes an Image. You are required to be logged in as the user whom created the image. 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 DeleteImageAsync ( string imageId, string username = "me" ) : Task
imageId string The image id.
username string The user account. Default: me
return Task
        public async Task<bool> DeleteImageAsync(string imageId, string username = "me")
        {
            if (string.IsNullOrWhiteSpace(imageId))
                throw new ArgumentNullException(nameof(imageId));

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

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

            var url = $"account/{username}/image/{imageId}";

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

Usage Example

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

            var deleted = await endpoint.DeleteImageAsync("ra06GZN", "sarah");

            Assert.IsTrue(deleted);
        }
All Usage Examples Of Imgur.API.Endpoints.Impl.AccountEndpoint::DeleteImageAsync