Skip to content

Instantly share code, notes, and snippets.

@JayBazuzi
Last active March 10, 2016 16:52
Show Gist options
  • Save JayBazuzi/120e900f8f7cb39e970d to your computer and use it in GitHub Desktop.
Save JayBazuzi/120e900f8f7cb39e970d to your computer and use it in GitHub Desktop.
interface IFooStatusReportsListener
{
void Notify(string productName, BarStatus[] barStatuses);
}
class BarClient
{
readonly HttpClient _httpClient = new HttpClient {BaseAddress = new Uri("https://bar.example.com/")};
public async void UpdateShippingStatusReports(string product, IFooStatusReportsListener listener)
{
var httpResponseMessage = await this._httpClient.GetAsync($"something/{product}").ConfigureAwait(false);
var result = await httpResponseMessage.EnsureSuccessStatusCode()
.Content.ReadAsAsync<BarStatus[]>().ConfigureAwait(false);
listener.Notify(product, result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment