static IAsyncPolicy <HttpResponseMessage> GetRetryPolicy(ExternalApiSettings settings) { return(HttpPolicyExtensions .HandleTransientHttpError() .OrResult(msg => msg.StatusCode == System.Net.HttpStatusCode.NotFound) .WaitAndRetryAsync(settings.RetryCount, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)))); }
public MovieController(ExternalApiSettings externalApiSettings, ILogger <MovieController> logger, IMemoryCache memoryCache) { _movieServices = new MovieServices(externalApiSettings, memoryCache); _externalApiSettings = externalApiSettings; _logger = logger; _cache = memoryCache; }
public Testing_BuildURLServices() { _externalApiSettings = new ExternalApiSettings { BaseUrl = "https://webjetapitest.azurewebsites.net/api", TokenValue = "x-access-token", TokenName = "sjd1HfkjU83ksdsm3802k" }; }
public WeatherMeasureService(IWeatherMeasureRepository weatherMeasureRepository, IMapper mapper, IExternalApiWeatherHandler externalApiWeatherHandler, ICityRepository cityRepository, IOptions <ExternalApiSettings> externalApiSettings) { _WeatherMeasureRepository = weatherMeasureRepository; _mapper = mapper; _externalApiWeatherHandler = externalApiWeatherHandler; _externalApiSettings = externalApiSettings.Value; _cityRepository = cityRepository; }
public string GetURL(string id, string provider, ExternalApiSettings externalApiSettings) { string hostname = externalApiSettings.BaseUrl; provider = "/" + provider; id = "/" + id; string endpoint = Constants.MovieEndpoint; return(GetBaseURL(hostname, provider, endpoint) + id); }
public List <string> GetURL(ExternalApiSettings externalApiSettings) { List <string> urls = new List <string>(); string hostname = externalApiSettings.BaseUrl; List <string> providers = APIProviders.Providers(); string endpoint = Constants.MoviesEndpoint; foreach (string provider in providers) { urls.Add(GetBaseURL(hostname, provider, endpoint)); } return(urls); }
public GetMovies(ExternalApiSettings externalApiSettings) { _externalApiSettings = externalApiSettings; _buildURLService = new BuildURLServices(); }
/// <summary> /// The class constructor. /// </summary> /// <param name="externalApiSettings">The <see cref="ExternalApiSettings"/>.</param> public EtherscanClient(ExternalApiSettings externalApiSettings) { this.externalApiSettings = externalApiSettings; this.client = new HttpClient(); }
/// <summary> /// Initializes a new instance of the <see cref="HealthCheckFunction"/> class. /// </summary> /// <param name="settings"><see cref="ExternalApiSettings"/> instance.</param> /// <param name="httpClient"><see cref="HttpClient"/> instance.</param> public HealthCheckFunction(ExternalApiSettings settings, HttpClient httpClient) { this._settings = settings ?? throw new ArgumentNullException(nameof(settings)); this._httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient)); }
public MovieServices(ExternalApiSettings externalApiSettings, IMemoryCache memoryCache) { _externalApiSettings = externalApiSettings; _cache = memoryCache; }
/// <summary> /// Class constructor. /// </summary> /// <param name="externalApiSettings">The <see cref="ExternalApiSettings"/>.</param> public CoinGeckoClient(ExternalApiSettings externalApiSettings) { this.externalApiSettings = externalApiSettings; this.client = new HttpClient(); }
public ExchangeRateAdapter(HttpClient client, IOptions <ExternalApiSettings> externalApiSettings) { _client = client; _externalApiSettings = externalApiSettings.Value; }