Пример #1
0
        public async Task <string> CallSummonerV4ByNameAsync(string str)
        {
            string calling = $"https://{RegionalEndpoints.GetEndPoint("NA")}{Apiendpoints.GetSummonerv4ByName(str)}";

            //client.BaseAddress = new Uri(calling);
            client.DefaultRequestHeaders.Add("X-Riot-Token", ApiKey.Apikey);
            client.DefaultRequestHeaders.Add("ContentType", "application/json");

            var res = await client.GetAsync(calling);

            return(res.ToString());
        }
Пример #2
0
        public SummonerByNameV4Model CallSummonerV4ByNameModel(string str)
        {
            string calling = $"https://{RegionalEndpoints.GetEndPoint("NA")}{Apiendpoints.GetSummonerv4ByName(str)}";

            Request             = (HttpWebRequest)WebRequest.Create(calling);
            Request.Method      = "GET";
            Request.ContentType = "application/json";
            Request.Headers.Add("X-Riot-Token", ApiKey.Apikey);

            try
            {
                WebResponse webResponse = Request.GetResponse();
                using (Stream webStream = webResponse.GetResponseStream() ?? Stream.Null)
                    using (StreamReader responseReader = new StreamReader(webStream))
                    {
                        return(JsonConvert.DeserializeObject <SummonerByNameV4Model>(responseReader.ReadToEnd()));
                    }
            }
            catch (Exception)
            {
                //TODO: ADD EXCEPTION MESSAGE HERE
            }
            return(new SummonerByNameV4Model());
        }
Пример #3
0
        public string CallSummonerV4ByName(string str)
        {
            string calling = $"https://{RegionalEndpoints.GetEndPoint("NA")}{Apiendpoints.GetSummonerv4ByName(str)}";

            Request             = (HttpWebRequest)WebRequest.Create(calling);
            Request.Method      = "GET";
            Request.ContentType = "application/json";
            Request.Headers.Add("X-Riot-Token", ApiKey.Apikey);

            try
            {
                WebResponse webResponse = Request.GetResponse();
                using (Stream webStream = webResponse.GetResponseStream() ?? Stream.Null)
                    using (StreamReader responseReader = new StreamReader(webStream))
                    {
                        return(responseReader.ReadToEnd());
                    }
            }
            catch (Exception)
            {
                //todo add message here
            }
            return(string.Empty);
        }