public async Task <string> GetLatestReleaseNotes()
        {
            var latestRelease = await GetLatestRelease();

            var latestReleaseNotesUrl = new Uri($"http://chromedriver.storage.googleapis.com/{latestRelease}/notes.txt");
            var latestReleaseNotes    = await _httpClientWrapper.GetStringAsync(latestReleaseNotesUrl);

            return(latestReleaseNotes);
        }
Beispiel #2
0
        public async Task <decimal> GetActualCurrencyRate(CurrencyShorcutEnum currencyShorcutEnum)
        {
            string url = GetUrl(GetCurrency(currencyShorcutEnum));

            var json = await httpClientHandler.GetStringAsync(url);

            if (string.IsNullOrEmpty(json))
            {
                return(0);
            }

            var currency = JsonConvert.DeserializeObject <NbpCurrencyModel>(json);

            return(currency.rates.First().mid);
        }
Beispiel #3
0
        public async Task <MovieListDto> GetFilmWorldMovieListAsync(CancellationToken cancelationToken)
        {
            try
            {
                var data = await _httpClientWrapper.GetStringAsync(_movieApiUris.GetFilmworldMovieList, CreateApiCancelationToken(cancelationToken));

                return(JsonConvert.DeserializeObject <MovieListDto>(data));
            }
            catch (Exception e)
            {
                _logger.Error("Failed to retrieve list of FilmWorld movies", e);
            }

            return(new MovieListDto());
        }
Beispiel #4
0
        public async Task <T> Scrape()
        {
            var content = await HttpClientClient.GetStringAsync(Uri);

            var dom = new CQ(content);

            return(Parse(dom));
        }
Beispiel #5
0
        public JsonResult GetRates()
        {
            var rawResponse = _httpClient.GetStringAsync(_apiConfig.Value.Url).Result;
            var xmlResponse = _xmlSerializer.Deserialize <ForexResponse>(rawResponse);

            var selectedCurrencyCodes = new[] { "USD", "EUR" };
            var selectedRates         = xmlResponse.Rates.Where(rate => selectedCurrencyCodes.Contains(rate.CurrencyCode)).ToArray();

            var jsonModel = _mapper.MapToJsonModel(xmlResponse.UpdatedOn, selectedRates);

            return(new JsonResult(jsonModel));
        }
Beispiel #6
0
        private async Task <string> GetContentAsync(string link)
        {
            var content = "";

            try {
                content = await _client.GetStringAsync(link);
            }
            catch {
                // ignored
            }
            return(content);
        }
Beispiel #7
0
        public async Task <string> Resize(string rawImageUrl, int maxHeight, int maxWide)
        {
            string uriMaxHeight = string.Format(
                CultureInfo.InvariantCulture,
                ResizeApiTemplate,
                Uri.EscapeDataString(rawImageUrl),
                "resize_h=" + maxHeight);

            string uriMaxWide = string.Format(
                CultureInfo.InvariantCulture,
                ResizeApiTemplate,
                Uri.EscapeDataString(rawImageUrl),
                "resize_w=" + maxWide);

            string uriNoResize = string.Format(
                CultureInfo.InvariantCulture,
                NoResizeApiTemplate,
                Uri.EscapeDataString(rawImageUrl));

            using (IHttpClientWrapper client = this.httpFactory.CreateHttpClient())
            {
                var contentHTask = client.GetStringAsync(uriMaxHeight);
                var contentWTask = client.GetStringAsync(uriMaxWide);
                var noResizeTask = client.GetStringAsync(uriNoResize);
                await Task.WhenAll(noResizeTask, contentHTask, contentWTask);

                int minLen = Math.Min(noResizeTask.Result.Length, Math.Min(contentHTask.Result.Length, contentWTask.Result.Length));

                if (minLen == contentHTask.Result.Length)
                {
                    return(uriMaxHeight);
                }
                else if (minLen == contentWTask.Result.Length)
                {
                    return(uriMaxWide);
                }

                return(rawImageUrl);
            }
        }
 private async Task <string> GetString(string url, string accessToken)
 {
     return(await _httpClientWrapper.GetStringAsync(url));
 }