From 480f0052ff2ca946ee2be6d92f9c74deeb3c1522 Mon Sep 17 00:00:00 2001 From: itowlson Date: Fri, 23 Apr 2021 11:02:13 +1200 Subject: [PATCH] Yank invoice (#4) --- Bindle.Tests/Integration.cs | 12 ++++++++++++ Bindle/BindleClient.cs | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/Bindle.Tests/Integration.cs b/Bindle.Tests/Integration.cs index 3f9d611..bcaa8a2 100644 --- a/Bindle.Tests/Integration.cs +++ b/Bindle.Tests/Integration.cs @@ -100,5 +100,17 @@ public async Task CanCreateInvoices() Assert.Equal(invoice.Parcels[1].Label.Feature["test"]["a"], fetched.Parcels[1].Label.Feature["test"]["a"]); Assert.Equal(invoice.Groups.Count, fetched.Groups.Count); } + + [Fact] + public async Task CanYankInvoice() + { + var client = new BindleClient(DEMO_SERVER_URL); + await client.YankInvoice("your/fancy/bindle/0.3.0"); // TODO: use one that doesn't conflict with CanFetchInvoice (because Xunit parallelisation) + await Assert.ThrowsAsync(async () => { + await client.GetInvoice("your/fancy/bindle/0.3.0"); + }); + var invoice = await client.GetInvoice("your/fancy/bindle/0.3.0", IncludeYanked); + Assert.Equal("your/fancy/bindle", invoice.Bindle.Name); + } } } diff --git a/Bindle/BindleClient.cs b/Bindle/BindleClient.cs index 73c1401..8647568 100644 --- a/Bindle/BindleClient.cs +++ b/Bindle/BindleClient.cs @@ -67,6 +67,13 @@ public async Task CreateInvoice(Invoice invoice) return Parser.ParseCreateInvoiceResult(toml); } + public async Task YankInvoice(string invoiceId) + { + var httpClient = new HttpClient(); + var uri = new Uri(_baseUri, INVOICE_PATH + "/" + invoiceId); + await httpClient.DeleteAsync(uri); + } + private static string SlashSafe(string uri) { if (uri.EndsWith('/'))