public TransformOrders GetOrder(string MainCoinName, string SecondCoinName) { if (MainCoinName == "USD") { return(new TransformOrders()); } TransformOrders temp = new TransformOrders(); string site = String.Format("https://www.cryptopia.co.nz/api/GetMarketOrders/{0}/30", SecondCoinName + '_' + MainCoinName); try { WebResponse resp = CryptoGetRequst.Requst(site); using (StreamReader stream = new StreamReader( resp.GetResponseStream(), Encoding.UTF8)) { string str = stream.ReadToEnd(); var res = JsonConvert.DeserializeObject <Field>(str); if (res.Success == true && res.Error == null) { temp = new TransformOrders(res.Data.Sell.ToDictionary(d => d.Price, k => k.Volume), res.Data.Buy.ToDictionary(d => d.Price, k => k.Volume)); } } return(temp); } catch (WebException e) { string message = e.Message; //MessageBoxButtons buttons = MessageBoxButtons.OK; //MessageBox.Show(message, "CRYPTO", buttons); return(temp); } }
public Dictionary <string, TransformInfo> GetInfo() { string site = "https://www.cryptopia.co.nz/api/GetCurrencies"; WebResponse resp = CryptoGetRequst.Requst(site); Dictionary <string, TransformInfo> temp = new Dictionary <string, TransformInfo>(); using (StreamReader stream = new StreamReader( resp.GetResponseStream(), Encoding.UTF8)) { string str = stream.ReadToEnd(); var res = JsonConvert.DeserializeObject <Field>(str); temp = res.Data.ToDictionary(d => d.Symbol, d => new TransformInfo(d)); } return(temp); }