Skip to content

Instantly share code, notes, and snippets.

@alefcarlos
Created January 12, 2019 06:38
Show Gist options
  • Save alefcarlos/e3e6d0e1f4df0653489b95fd9a175b31 to your computer and use it in GitHub Desktop.
Save alefcarlos/e3e6d0e1f4df0653489b95fd9a175b31 to your computer and use it in GitHub Desktop.
using System;
using System.Net.Http;
using System.Threading.Tasks;
namespace ConsoleApp
{
public class ApiService
{
private readonly HttpClient _client;
public ApiService(HttpClient client)
{
_client = client;
_client.DefaultRequestHeaders.Accept.Clear();
_client.BaseAddress = new System.Uri("https://localhost:5000/api/");
}
public async Task TimeoutAsync(int timeoutSeconds, int retrySuccess)
{
var response = await _client.GetAsync($"example/timeout/{timeoutSeconds}/complete/{retrySuccess}");
}
public async Task ErrorAsync(int errorCode, int retrySuccess)
{
var response = await _client.GetAsync($"example/error/{errorCode}/complete/{retrySuccess}");
}
public async Task SuccessAsync()
{
var response = await _client.GetAsync("example/success/");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment