public void QuotesQuery_Test() { CLQuotesResponse response = CLQueryBuilder. Create(Endpoints.RATES). SetAccessKey(TestConfiguration.ApiAccessKey). GetResult <CLQuotesResponse>(); Assert.IsNotNull(response); Assert.IsTrue(response.Success); }
public static IEnumerable <Quote> ToQuotes(this CLQuotesResponse response) { return(response.Quotes.Select(q => { string targetCurrency = q.Key.Substring(3); return new Quote() { SourceCurrency = Currency.FromCode(response.Source), TargetCurrency = Currency.FromCode(targetCurrency), Rate = q.Value }; })); }
public static IEnumerable <Quote> ToHistoricalQuotes(this CLQuotesResponse response) { if (!response.Historical) { throw new Exception("The specified response is not historical"); } return(response.Quotes.Select(q => { string targetCurrency = q.Key.Substring(3); return new HistoricalQuote() { SourceCurrency = Currency.FromCode(response.Source), TargetCurrency = Currency.FromCode(targetCurrency), // for historical response date always should be set. The case when Date has no value should be considered as bug Date = response.Date.Value, Rate = q.Value }; })); }