public string GetRankedInfo(SummonerDto sum) { if (sum == null || sum.id == 0) { return(""); } var json = WebTalker.HttpGet(RankedInfo + sum.id + Entry + _apitail); if (json.Equals("")) { return("RITO ERROR PLS"); } var renked = JObject.Parse(json).SelectToken(sum.id.ToString()).ToString(); var obj = JsonConvert.DeserializeObject <List <LeagueDto> >(renked); var s = "-\n" + sum.name + ":"; foreach (var leagueDto in obj.Where(leagueDto => leagueDto.entries != null)) { if (leagueDto.queue.Equals(Sq)) { s += string.Format("\n{0}: {1} {2} {3}LP", leagueDto.queue, leagueDto.tier, leagueDto.entries.First().division, leagueDto.entries.First().leaguePoints); } else { s += string.Format("\n{0}: {1} {2} {3} {4}LP", leagueDto.queue, leagueDto.entries.First().playerOrTeamName, leagueDto.tier, leagueDto.entries.First().division, leagueDto.entries.First().leaguePoints); } } s = s.Replace(Rt5, NewRt5).Replace(Rt3, NewRt3).Replace(Sq, NewSq).Replace(BRONZE, Bronze).Replace(SILVER, Silver).Replace(GOLD, Gold).Replace(PLATINUM, Platinum).Replace(DIAMOND, Diamond).Replace(CHALLENGER, Challenger).Replace(MASTER, Master); return(s); }
public SummonerDto SummonerIdByName(string name) { var json = WebTalker.HttpGet(apihead + IdByName + name + _apitail); if (json.Equals("")) { return(null); } var sums = JObject.Parse(json).SelectToken(name.ToLower().Replace(" ", string.Empty)).ToString(); var obj = JsonConvert.DeserializeObject <SummonerDto>(sums); return(obj); }
public static string GetResponse(string input) { input = WebUtility.UrlEncode(input); var xml = WebTalker.HttpGet(Baseurl + input); if (xml == "") { return(""); } var deserializer = new XmlSerializer(typeof(result)); TextReader reader = new StringReader(xml); var obj = deserializer.Deserialize(reader); var resultje = (result)obj; reader.Close(); return(resultje.that == null ? "Error: Expected parameter, got none." : resultje.that.Replace("<br>", Environment.NewLine)); }
public string Calculate(string expression) { var uri = _baseUrl + "&input=" + WebUtility.UrlEncode(expression.Trim()) + Tail; var xml = WebTalker.HttpGet(uri); if (xml == "") { return(""); } var deserializer = new XmlSerializer(typeof(queryresult)); TextReader reader = new StringReader(xml); var obj = deserializer.Deserialize(reader); var result = (queryresult)obj; reader.Close(); var output = string.Format("Input: {0}", expression); var outcome = string.Empty; foreach (var podje in result.Pods) { if (!podtitlesList.Contains(podje.Title)) { continue; } outcome = podje.Subpods.Aggregate(outcome, (current, subpodje) => current + (subpodje.plaintext + Environment.NewLine)); outcome = outcome.TrimEnd('\r', '\n'); break; } output += string.IsNullOrEmpty(outcome) ? "\nNo result found. :(" : "\n" + outcome; Debug.WriteLine(output); return(output); }