public static void Execute(IExchangeRatesClient client, DailyTimeSeries options) { var model = client.GetDailyTimeSeries(options.StartDate, options.EndDate, options.BaseCurrencyIsoCode.ToUpper(), options.CurrencyIsoCode.ToUpper()).Result; System.Console.WriteLine($"{model.ResultsInfo.IsoCode} {model.ResultsInfo.Currency}"); System.Console.WriteLine(); System.Console.WriteLine($"Ref. date Rate"); foreach (var rate in model.Rates) { System.Console.WriteLine( $"{rate.ReferenceDate:yyyy-MM-dd} {rate.AvgRate,16:N6} {model.ResultsInfo.ExchangeConventionCode,1}"); } System.Console.WriteLine(); System.Console.WriteLine(model.ResultsInfo.TimezoneReference); System.Console.WriteLine("Exchange convention:"); System.Console.WriteLine( $"{model.ResultsInfo.ExchangeConventionCode} {model.Rates.FirstOrDefault()?.ExchangeConvention}"); }
public async Task GetDailyTimeSeries() { var startDate = new DateTime(2020, 12, 30); var endDate = new DateTime(2020, 12, 31); var rates = new DailyTimeSeriesModel.ExchangeRateModel[] { new DailyTimeSeriesModel.ExchangeRateModel { ReferenceDate = startDate, AvgRate = 1.1652, ExchangeConvention = "Foreign currency amount for 1 Euro", }, new DailyTimeSeriesModel.ExchangeRateModel { ReferenceDate = endDate, AvgRate = 1.1625, ExchangeConvention = "Foreign currency amount for 1 Euro", } }; var expected = new DailyTimeSeriesModel { ResultsInfo = new DailyTimeSeriesModel.ResultsInfoModel { TotalRecords = rates.Length, TimezoneReference = "Dates refer to the Central European Time Zone", Currency = "U.S. Dollar", IsoCode = "USD", UicCode = "001", ExchangeConventionCode = "C" }, Rates = rates }; var actual = await _client.GetDailyTimeSeries(startDate, endDate, "USD", "EUR"); Assert.Equal(JsonConvert.SerializeObject(expected), JsonConvert.SerializeObject(actual)); }