Exemplo n.º 1
0
        public async Task <ExchangeRateProviderModel> FetchRateAsync(string baseCurrency, string counterCurrency)
        {
            string apiKey     = _apiKey;
            string code       = $"{baseCurrency}_{counterCurrency}";
            string requestUri = $"{_uri}?q={code}&compact=ultra&apiKey={apiKey}";
            string json;

            using (HttpClient client = new HttpClient())
            {
                json = await client.GetStringAsync(requestUri);
            }

            Dictionary <string, decimal> jsonObject = JsonConvert.DeserializeObject <Dictionary <string, decimal> >(json);
            decimal rate = jsonObject[code];

            ExchangeRateProviderModel result = new ExchangeRateProviderModel(ProviderName, baseCurrency, counterCurrency, rate, rate);

            return(result);
        }
Exemplo n.º 2
0
        public Task <ExchangeRateProviderModel> FetchRateAsync(string baseCurrency, string counterCurrency)
        {
            var result = new ExchangeRateProviderModel(ProviderName, baseCurrency, counterCurrency, DEFAULT_VALUE, DEFAULT_VALUE);

            return(Task.FromResult(result));
        }