Пример #1
0
        public static CurrentGame RequestCurrentGame(ApiResourceBuilder.ServerRegion serverRegion, string summonerName)
        {
            string apiBaseUrl = ApiResourceBuilder.GetApiBaseUrl(serverRegion);

            //Getting summoner ID
            string url = ApiResourceBuilder.GetResourceUrl(serverRegion, ApiResourceBuilder.ApiResource.Summoner);
            url += "by-name/" + summonerName;

            Console.WriteLine("requesting summoner info");

            ApiResponse summonerResponse = RestApiProxy.GetRequest(url, null);

            Console.WriteLine("summoner info fetched");

            if (summonerResponse.StatusCode == System.Net.HttpStatusCode.OK) {
                var s = Summoner.DeserializeSummonerByName(summonerResponse.JsonString);

                var summonerId = s.id;

                var currentGameUrlString = ApiResourceBuilder.GetCurrentGameUrl(serverRegion, summonerId);

                var currentGameResponse = RestApiProxy.GetRequest(currentGameUrlString);

                CurrentGame currentGame = CurrentGame.DeserializeCurrentGame(currentGameResponse.JsonString);

                return currentGame;
            }

            return null;
        }
Пример #2
0
        public static CurrentGameModel GetCurrentGameModel(ApiResourceBuilder.ServerRegion serverRegion, string summonerName)
        {
            Console.WriteLine("Requesting CurrentGameModel");

            CurrentGame currentGame = ApiHelper.RequestCurrentGame(serverRegion, summonerName);

            Console.WriteLine("CurrentGame has been fetched via the API");

            return CreateCurrentGameModel(currentGame);
        }