Last active
June 12, 2023 23:53
-
-
Save loic-sharma/ab2f857e63ae6258bb739529102970e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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