public async Task <T> DownloadCurrenciesAsync <T>(BaseMoneyCurrency currentCurrency, CancellationToken cancellationToken) { using (var client = new HttpClient()) using (cancellationToken.Register(() => client.CancelPendingRequests())) { var response = await client.GetAsync(GetHttpRequestUri(currentCurrency), cancellationToken).ConfigureAwait(false); if (response.Content == null) { throw new ArgumentNullException("Content is missing"); } var result = await response.Content.ReadAsStringAsync().ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); return(JsonConvert.DeserializeObject <T>(result)); } }
public Uri GetHttpRequestUri(BaseMoneyCurrency baseCurrency) => new Uri(BaseApiEndpoint + Resources.Token + "/latest/" + supportedBaseCurrencyDictionary[baseCurrency]);