Skip to content

Commit

Permalink
Yank invoice (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
itowlson authored Apr 22, 2021
1 parent 5453d12 commit 480f005
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Bindle.Tests/Integration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<System.Net.WebException>(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);
}
}
}
7 changes: 7 additions & 0 deletions Bindle/BindleClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ public async Task<CreateInvoiceResult> 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('/'))
Expand Down

0 comments on commit 480f005

Please # to comment.