Exemplo n.º 1
0
        public async static Task <Currencies> GetCotacoes()
        {
            try
            {
                HttpClient client = new HttpClient();
                string     url    = "https://api.hgbrasil.com/finance";

                var response = await client.GetStringAsync(url);

                //var cotacoes = JsonConvert.DeserializeObject<Currencies>(response);
                var cotacoes = ConvertJson.FromJson(response);


                return(cotacoes.Results.Currencies);
            }
            catch (Exception)
            {
                return(null);
            }
        }
 public static string ToJson(this ConvertJson self) => JsonConvert.SerializeObject(self, SaldoBancarioAPI.Services.HGCotacoes.Converter.Settings);