示例#1
0
        public async Task <ResponseInfo <CurrencyRatesResponse> > GetLatestRates(string baseCode, string targetCodes)
        {
            var url    = $"{AppConfigurations.ApiUrl}GetLatestRates?baseCode={baseCode}&targetCodes={targetCodes}&api-version=1.0";
            var result = new ResponseInfo <CurrencyRatesResponse>();

            try
            {
                var response = await _httpClientService.CreateClient().GetAsync(url);

                if (response.IsSuccessStatusCode)
                {
                    var responseString = await response.Content.ReadAsStringAsync();

                    result = SerializerHelper.FromJson <ResponseInfo <CurrencyRatesResponse> >(responseString);
                }
                return(result);
            }
            catch
            {
                result.Message = "Service unavailable.";
                return(result);
            }
        }
示例#2
0
        /// <summary>
        /// Busca na ApiOne a taxa de juros (Fixo em codigo 0,01)
        /// </summary>
        /// <returns>Retorna a taxa de juros</returns>
        private async Task <string> GetTaxFromApiOne()
        {
            _client?.CreateClient();

            HttpResponseMessage response = await _client?.GetAsync("http://192.168.15.11:4000/api/taxajuros");

            if (response != null && response.IsSuccessStatusCode)
            {
                return(await response.Content.ReadAsStringAsync());
            }
            else
            {
                return(null);
            }
        }