11using System . Text . Json ;
22using Microsoft . AspNetCore . WebUtilities ;
3+ using Microsoft . Extensions . Configuration ;
34using Microsoft . Extensions . Logging ;
45using Services . Extensions ;
56using Services . Models ;
67using Services . Utility ;
78
89namespace Services ;
910
10- public class MarketClient ( ILogger < MarketClient > logger , IHttpClientFactory httpClientFactory ) : IMarketClient
11+ public class MarketClient ( ILogger < MarketClient > logger , IConfiguration configuration , IHttpClientFactory httpClientFactory ) : IMarketClient
1112{
1213 private readonly ILogger < MarketClient > _logger = logger ;
1314 private readonly IHttpClientFactory _httpClientFactory = httpClientFactory ;
@@ -16,13 +17,14 @@ public class MarketClient(ILogger<MarketClient> logger, IHttpClientFactory httpC
1617
1718 public async Task < List < MarketChartPoint > ? > GetMarketChartByDateRange ( DateOnly fromDate , DateOnly toDate )
1819 {
19- var baseUrl = $ "https:// api.coingecko.com/api/ v3/coins/{ Constants . CryptoCurrency } /market_chart/range";
20- var parameters = QueryHelper . CreateQueryParams ( fromDate , toDate , Constants . Currency ) ;
20+ const string baseUrl = "/ api/ v3/coins/bitcoin /market_chart/range";
21+ var parameters = QueryHelper . CreateQueryParams ( fromDate , toDate , "eur" ) ;
2122 var url = QueryHelpers . AddQueryString ( baseUrl , parameters ) ;
2223 using var request = new HttpRequestMessage ( HttpMethod . Get , url ) ;
2324
2425 using ( var httpClient = _httpClientFactory . CreateClient ( ) )
2526 {
27+ httpClient . BaseAddress = new Uri ( configuration . GetValue ( "MARKET_CLIENT_URL" , "https://api.coingecko.com" ) ) ;
2628 var response = await httpClient . SendAsync ( request ) . ConfigureAwait ( false ) ;
2729 if ( response . IsSuccessStatusCode )
2830 {
0 commit comments