/// <param name="timeout">Timeout affects all request. Leave it null if you do not want timeout.</param> private void InitBlockchainApiClient(ILog log, string hostUrl, int retriesCount = 5, TimeSpan?timeout = null, HttpMessageHandler messageHandler = null) { HostUrl = hostUrl ?? throw new ArgumentNullException(nameof(hostUrl)); _httpClient = new HttpClient(new HttpErrorLoggingHandler(log, messageHandler)) { BaseAddress = new Uri(hostUrl), DefaultRequestHeaders = { { "User-Agent", $"{PlatformServices.Default.Application.ApplicationName}/{PlatformServices.Default.Application.ApplicationVersion}" } } }; if (timeout.HasValue) { _httpClient.Timeout = timeout.Value; } _api = RestService.For <IBlockchainApi>(_httpClient); _runner = new ApiRunner(retriesCount); }
public BlockchainApiClient(string hostUrl, int retriesCount = 5) { HostUrl = hostUrl ?? throw new ArgumentNullException(nameof(hostUrl)); _httpClient = new HttpClient { BaseAddress = new Uri(hostUrl), DefaultRequestHeaders = { { "User-Agent", $"{PlatformServices.Default.Application.ApplicationName}/{PlatformServices.Default.Application.ApplicationVersion}" } } }; _api = RestService.For <IBlockchainApi>(_httpClient); _runner = new ApiRunner(retriesCount); }