public bool CoinHillsQuery(string CryptoCurrSym, string FiatCurrSym, ref CCResult result) { string CryptoCoin = CryptoCurrSym.ToLower(); string FiatCoin = FiatCurrSym.ToLower(); HttpResponseMessage Response = CoinHillsClient.GetAsync("v1/cspa/" + CryptoCoin + "/" + FiatCoin).Result; if (Response.IsSuccessStatusCode) { string Product = Response.Content.ReadAsStringAsync().Result; dynamic ParsedProduct = Newtonsoft.Json.Linq.JObject.Parse(Product); if ((bool)ParsedProduct["success"]) { string CSPAString = "CSPA:" + CryptoCoin.ToUpper() + "/" + FiatCoin.ToUpper(); result.price = (decimal)ParsedProduct["data"][CSPAString]["cspa"]; result.status = "OK."; return(true); } else { result.price = 0; result.status = ParsedProduct["message"]; return(false); } } else { result.price = 0; result.status = Response.ReasonPhrase; return(false); } }
public bool CryptoCompareQuery(string FromCurrSym, string ToCurrSym, string Market, ref CCResult result) { string FromUpper = FromCurrSym.ToUpper(); string ToUpper = ToCurrSym.ToUpper(); HttpResponseMessage Response = CryptoCompareClient.GetAsync("data/price?fsym=" + FromUpper + "&tsyms=" + ToUpper + "&e=" + Market).Result; if (Response.IsSuccessStatusCode) { string Product = Response.Content.ReadAsStringAsync().Result; var Values = JsonConvert.DeserializeObject <Dictionary <string, dynamic> >(Product); if (Values.ContainsKey(ToUpper)) { result.price = (decimal)Values[ToUpper]; result.status = "OK."; return(true); } else { result.price = 0; result.status = Values["Message"]; return(false); } } else { result.price = 0; result.status = Response.ReasonPhrase; return(false); } }