diff --git a/Bynder/Sample/MediaSample.cs b/Bynder/Sample/MediaSample.cs index 501d496..1840902 100644 --- a/Bynder/Sample/MediaSample.cs +++ b/Bynder/Sample/MediaSample.cs @@ -70,6 +70,13 @@ private async Task RunMediaSampleAsync() Description = updatedDescription }; await _bynderClient.GetAssetService().ModifyMediaAsync(modifyMediaQuery); + + + // Modify a media with a new description + Console.WriteLine("Enter the media ID to delete: "); + var mediaIdForDelete = Console.ReadLine(); + await _bynderClient.GetAssetService().DeleteAssetAsync(mediaIdForDelete); + } private async Task AuthenticateWithOAuth2Async(bool useClientCredentials) diff --git a/Bynder/Sdk/Service/Asset/AssetService.cs b/Bynder/Sdk/Service/Asset/AssetService.cs index f94f779..d5e15ba 100644 --- a/Bynder/Sdk/Service/Asset/AssetService.cs +++ b/Bynder/Sdk/Service/Asset/AssetService.cs @@ -232,5 +232,18 @@ public async Task DeleteAssetUsage(AssetUsageQuery query) Query = query }).ConfigureAwait(false); } + + /// + /// Check for more information + /// + /// Check for more information + public async Task DeleteAssetAsync(string assetId) + { + return await _requestSender.SendRequestAsync(new ApiRequest + { + Path = "/api/v4/media/" + assetId, + HTTPMethod = HttpMethod.Delete, + }).ConfigureAwait(false); + } } } diff --git a/Bynder/Sdk/Service/Asset/IAssetService.cs b/Bynder/Sdk/Service/Asset/IAssetService.cs index 8f0a7d8..17b687a 100644 --- a/Bynder/Sdk/Service/Asset/IAssetService.cs +++ b/Bynder/Sdk/Service/Asset/IAssetService.cs @@ -122,5 +122,13 @@ public interface IAssetService /// Can be thrown when requests to server can't be completed or HTTP code returned by server is an error Task DeleteAssetUsage(AssetUsageQuery query); + /// + /// Delete an asset + /// + /// Id of the asset to remove + /// Task representing the operation + /// Can be thrown when requests to server can't be completed or HTTP code returned by server is an error + Task DeleteAssetAsync(string assetId); + } } diff --git a/Bynder/Test/Service/Asset/AssetServiceTest.cs b/Bynder/Test/Service/Asset/AssetServiceTest.cs index 8b2d497..4b633c8 100644 --- a/Bynder/Test/Service/Asset/AssetServiceTest.cs +++ b/Bynder/Test/Service/Asset/AssetServiceTest.cs @@ -257,5 +257,23 @@ public async Task DeleteAssetUsageCallsRequestSenderWithValidRequest() ) )); } + + [Fact] + public async Task DeleteAssetCallsRequestSenderWithValidRequest() + { + var result = new Status { Message = "Accepted", StatusCode = 204 }; + _apiRequestSenderMock.Setup(sender => sender.SendRequestAsync(It.IsAny>())) + .ReturnsAsync(result); + + var assetId = "asset-id"; + await _assetService.DeleteAssetAsync(assetId); + + _apiRequestSenderMock.Verify(sender => sender.SendRequestAsync( + It.Is>(req => + req.Path == $"/api/v4/media/" + assetId + && req.HTTPMethod == HttpMethod.Delete + ) + )); + } } }