Skip to content

Instantly share code, notes, and snippets.

@loic-sharma
Last active June 12, 2023 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loic-sharma/ab2f857e63ae6258bb739529102970e7 to your computer and use it in GitHub Desktop.
Save loic-sharma/ab2f857e63ae6258bb739529102970e7 to your computer and use it in GitHub Desktop.
using System.Net.Http.Json;
public class CurrencyRepo : RepoBase, ICurrencyRepo
{
private readonly HttpClient _http;
private readonly string _baseUrl;
public CurrencyRepo(
HttpClient http,
string baseUrl)
{
_http = http;
_baseUrl = baseUrl;
}
public override async Task<HashSet<Currency>> GetCurrenciesAsync()
{
var currencies = await _http.GetFromJsonAsync<List<Currency>>(
$"{_baseUrl}/currencies");
return new HashSet<Currency>(currencies!);
}
}
public record Currency();
public interface ICurrencyRepo
{
Task<HashSet<Currency>> GetCurrenciesAsync();
}
public class RepoBase : ICurrencyRepo
{
public virtual Task<HashSet<Currency>> GetCurrenciesAsync()
{
throw new NotImplementedException();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment