Esempio n. 1
0
        public async Task <SummonerSpellStatic> RetrieveSummonerSpellData(CreepScore.Region region, int id, StaticDataConstants.SpellData spellData, string locale = "", string version = "")
        {
            Url url = UrlConstants.StaticDataUrlBuilder(region, UrlConstants.summonerSpellPart).AppendPathSegment(id.ToString());

            url.SetQueryParams(new
            {
                locale    = locale,
                version   = version,
                spellData = StaticDataConstants.GetSpellData(spellData),
                api_key   = apiKey
            });
            Uri uri = new Uri(url.ToString());

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(HelperMethods.LoadSummonerSpellStatic(JObject.Parse(responseString)));
        }
        async Task SaveRegionSetting()
        {
            AppConstants.preferredRegion = (CreepScore.Region)AppConstants.GetCreepScoreRegion(regionComboBox.SelectedIndex);
            StorageFile regionFile = await AppConstants.TryCreateFile("Region.json", localFolder);

            await AppConstants.OverwriteFile(regionFile, UrlConstants.GetRegion(AppConstants.preferredRegion));
        }
Esempio n. 3
0
        public async Task <League> RetrieveChallengerLeague(CreepScore.Region region, GameConstants.Queue queue)
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.leagueAPIVersion, UrlConstants.leaguePart).AppendPathSegment("challenger");

            url.SetQueryParams(new
            {
                type    = GameConstants.GetQueue(queue),
                api_key = apiKey
            });
            Uri uri = new Uri(url.ToString());

            await GetPermission(region);

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(LoadLeague(JObject.Parse(responseString)));
        }
Esempio n. 4
0
        public async Task <RuneListStatic> RetrieveRunesData(CreepScore.Region region, StaticDataConstants.RuneListData runeListData, string locale = "", string version = "")
        {
            Url url = UrlConstants.StaticDataUrlBuilder(region, UrlConstants.runePart);

            url.SetQueryParams(new
            {
                locale       = locale,
                version      = version,
                runeListData = StaticDataConstants.GetRuneListData(runeListData),
                api_key      = apiKey
            });
            Uri uri = new Uri(url.ToString());

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(HelperMethods.LoadRuneListStatic(JObject.Parse(responseString)));
        }
Esempio n. 5
0
        public async Task <RecentGames> RetrieveRecentGames()
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.gameAPIVersion, UrlConstants.gamePart)
                      .AppendPathSegments(UrlConstants.bySummonerPart, id.ToString(), UrlConstants.recentPart);

            url.SetQueryParams(new
            {
                api_key = CreepScore.apiKey
            });
            Uri uri = new Uri(url.ToString());

            await CreepScore.GetPermission(region);

            string responseString;

            try
            {
                responseString = await CreepScore.GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(LoadRecentGames(JObject.Parse(responseString)));
        }
Esempio n. 6
0
        public async Task <Dictionary <string, RunePages> > RetrieveRunePages()
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.summonerAPIVersion, UrlConstants.summonerPart)
                      .AppendPathSegments(id.ToString(), UrlConstants.runesPart);

            url.SetQueryParams(new
            {
                api_key = CreepScore.apiKey
            });
            Uri uri = new Uri(url.ToString());

            await CreepScore.GetPermission(region);

            string responseString;

            try
            {
                responseString = await CreepScore.GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(LoadRunePages(responseString));
        }
Esempio n. 7
0
        public async Task <Dictionary <string, List <Team> > > RetrieveTeams()
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.teamAPIVersion, UrlConstants.teamPart)
                      .AppendPathSegments(UrlConstants.bySummonerPart, id.ToString());

            url.SetQueryParams(new
            {
                api_key = CreepScore.apiKey
            });
            Uri uri = new Uri(url.ToString());

            await CreepScore.GetPermission(region);

            string responseString;

            try
            {
                responseString = await CreepScore.GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(HelperMethods.LoadTeams(responseString));
        }
Esempio n. 8
0
        public async Task <PlayerStatsSummaryList> RetrievePlayerStatsSummaries(CreepScore.Season season)
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.statsAPIVersion, UrlConstants.statsPart)
                      .AppendPathSegments(UrlConstants.bySummonerPart, id.ToString(), UrlConstants.summaryPart);

            url.SetQueryParams(new
            {
                season  = CreepScore.GetSeason(season),
                api_key = CreepScore.apiKey
            });
            Uri uri = new Uri(url.ToString());
            await CreepScore.GetPermission(region);

            string responseString;

            try
            {
                responseString = await CreepScore.GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(LoadPlayerStatSummariesList(JObject.Parse(responseString), season));
        }
Esempio n. 9
0
        public async Task <RankedStats> RetrieveRankedStats(CreepScore.Season season)
        {
            if (summonerLevel == 30)
            {
                Url url = UrlConstants.UrlBuilder(region, UrlConstants.statsAPIVersion, UrlConstants.statsPart)
                          .AppendPathSegments(UrlConstants.bySummonerPart, id.ToString(), UrlConstants.rankedPart);
                url.SetQueryParams(new
                {
                    season  = CreepScore.GetSeason(season),
                    api_key = CreepScore.apiKey
                });
                Uri uri = new Uri(url.ToString());
                await CreepScore.GetPermission(region);

                string responseString;
                try
                {
                    responseString = await CreepScore.GetWebData(uri);
                }
                catch (CreepScoreException)
                {
                    throw;
                }
                return(LoadRankedStats(JObject.Parse(responseString), season));
            }
            else
            {
                throw new CreepScoreException("The summoner is not level 30. They do not have ranked stats.");
            }
        }
Esempio n. 10
0
        public async Task <List <Champion> > RetrieveChampions(CreepScore.Region region, bool freeToPlay = false)
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.championAPIVersion, UrlConstants.championPart);

            url.SetQueryParams(new
            {
                freeToPlay = freeToPlay.ToString(),
                api_key    = apiKey
            });
            Uri uri = new Uri(url.ToString());

            await GetPermission(region);

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(LoadChampions(JObject.Parse(responseString)));
        }
Esempio n. 11
0
        public async Task <ChampionListStatic> RetrieveChampionsData(CreepScore.Region region, StaticDataConstants.ChampData champData, string locale = "", string version = "", bool dataById = false)
        {
            Url url = UrlConstants.StaticDataUrlBuilder(region, UrlConstants.championPart);

            url.SetQueryParams(new
            {
                locale    = locale,
                version   = version,
                dataById  = dataById.ToString(),
                champData = StaticDataConstants.GetChampData(champData),
                api_key   = apiKey
            });
            Uri uri = new Uri(url.ToString());

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(LoadChampionListStatic(JObject.Parse(responseString)));
        }
Esempio n. 12
0
        public async Task <MatchDetailAdvanced> RetrieveMatch(CreepScore.Region region, long matchId, bool includeTimeline = false)
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.matchAPIVersion, UrlConstants.matchPart)
                      .AppendPathSegment(matchId.ToString());

            url.SetQueryParams(new
            {
                includeTimeline = includeTimeline.ToString(),
                api_key         = apiKey
            });
            Uri uri = new Uri(url.ToString());

            await GetPermission(region);

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(HelperMethods.LoadMatchDetailAdvanced(JObject.Parse(responseString)));
        }
Esempio n. 13
0
        public async Task <List <Summoner> > RetrieveSummoners(CreepScore.Region region, List <long> summonerIds)
        {
            string ids = "";

            if (summonerIds.Count > 40)
            {
                throw new CreepScoreException("Cannot retrieve more than 40 summoners at once.");
            }

            for (int i = 0; i < summonerIds.Count; i++)
            {
                if (i != summonerIds.Count - 1)
                {
                    ids += summonerIds[i].ToString() + ",";
                }
                else
                {
                    ids += summonerIds[i].ToString();
                }
            }

            Uri uri;

            if (ids != "")
            {
                Url url = UrlConstants.UrlBuilder(region, UrlConstants.summonerAPIVersion, UrlConstants.summonerPart)
                          .AppendPathSegment(ids);
                url.SetQueryParams(new
                {
                    api_key = apiKey
                });
                uri = new Uri(url.ToString());
            }
            else
            {
                throw new CreepScoreException("Cannot have an empty list of summoner IDs.");
            }

            await GetPermission(region);

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            List <Summoner> summoners           = new List <Summoner>();
            Dictionary <string, JObject> values = JsonConvert.DeserializeObject <Dictionary <string, JObject> >(responseString);

            foreach (KeyValuePair <string, JObject> value in values)
            {
                summoners.Add(new Summoner(value.Value, region));
            }
            return(summoners);
        }
Esempio n. 14
0
        public async Task SaveRegionSetting()
        {
            StorageFolder localFolder = ApplicationData.Current.LocalFolder;

            AppConstants.preferredRegion = (CreepScore.Region)AppConstants.GetCreepScoreRegion(comboBox.SelectedIndex);
            StorageFile regionFile = await AppConstants.TryCreateFile("Region.json", localFolder);

            await AppConstants.OverwriteFile(regionFile, UrlConstants.GetRegion(AppConstants.preferredRegion));
        }
Esempio n. 15
0
 public async Task <User> GetSelfInfo()
 {
     try
     {
         return(await GetAsync <User>(UrlConstants.UserInfoURL()));
     }
     catch (Exception e)
     {
         return(null);
     }
 }
 public async Task <TransactionsList> GetTransactionsHistory()
 {
     try
     {
         return(await GetAsync <TransactionsList>(UrlConstants.TransactionURL()));
     }
     catch (Exception e)
     {
         return(null);
     }
 }
Esempio n. 17
0
        public async Task <Dictionary <string, Team> > RetrieveTeam(CreepScore.Region region, List <string> teamIds)
        {
            string ids = "";

            if (teamIds.Count > 10)
            {
                throw new CreepScoreException("Cannot retrieve more than 10 teams at once.");
            }

            for (int i = 0; i < teamIds.Count; i++)
            {
                if (i != teamIds.Count - 1)
                {
                    ids += teamIds[i] + ",";
                }
                else
                {
                    ids += teamIds[i];
                }
            }

            Uri uri;

            if (ids != "")
            {
                Url url = UrlConstants.UrlBuilder(region, UrlConstants.teamAPIVersion, UrlConstants.teamPart)
                          .AppendPathSegment(ids);
                url.SetQueryParams(new
                {
                    api_key = apiKey
                });
                uri = new Uri(url.ToString());
            }
            else
            {
                throw new CreepScoreException("Cannot have an empty list of team IDs.");
            }

            await GetPermission(region);

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(HelperMethods.LoadTeam(responseString));
        }
Esempio n. 18
0
        public async Task <IEnumerable <RemoteUser> > SearchUsers(string pFilter)
        {
            try
            {
                var users = await PostAsync <List <RemoteUser> >(UrlConstants.UsersURL(), new UserFilter { filter = pFilter });

                return(users);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
        public async Task <Transaction> CreateTransaction(string userName, double amount)
        {
            try
            {
                var transaction = await PostAsync <Transaction>(UrlConstants.TransactionURL(), new TransactionData { name = userName, amount = amount });

                return(transaction);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
Esempio n. 20
0
        public async Task <string> Login(string pEmail, string pPassword)
        {
            try
            {
                var token = await PostAsync <Token>(UrlConstants.LoginURL(), new LoginUser { email = pEmail, password = pPassword });

                HttpClientFactory.AccessToken = token.ToString();
                return(token.ToString());
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Esempio n. 21
0
        public async Task <string> Register(string pUserame, string pPassword, string pEmail)
        {
            try
            {
                var token = await PostAsync <Token>(UrlConstants.RegisterUserURL(), new RegUser { username = pUserame, password = pPassword, email = pEmail });

                HttpClientFactory.AccessToken = token.ToString();
                return(token.ToString());
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Esempio n. 22
0
        public async Task <Dictionary <long, string> > RetrieveSummonerNames(CreepScore.Region region, List <long> summonerIds)
        {
            string summonerIdsPart = "";

            if (summonerIds.Count > 40)
            {
                throw new CreepScoreException("Cannot retrieve more than 40 summoners at once.");
            }

            for (int i = 0; i < summonerIds.Count; i++)
            {
                if (i != summonerIds.Count - 1)
                {
                    summonerIdsPart += summonerIds[i].ToString() + ",";
                }
                else
                {
                    summonerIdsPart += summonerIds[i].ToString();
                }
            }

            Url url = UrlConstants.UrlBuilder(region, UrlConstants.summonerAPIVersion, UrlConstants.summonerPart)
                      .AppendPathSegments(summonerIdsPart, UrlConstants.namePart);

            url.SetQueryParams(new
            {
                api_key = apiKey
            });
            Uri uri = new Uri(url.ToString());

            await GetPermission(region);

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(JsonConvert.DeserializeObject <Dictionary <long, string> >(responseString));
        }
Esempio n. 23
0
        public async Task <ShardStatus> RetrieveShardStatus(Region region)
        {
            Uri uri;

            uri = new Uri("http://status.leagueoflegends.com/shards/" +
                          UrlConstants.GetRegion(region));

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(LoadShardStatus(JObject.Parse(responseString)));
        }
Esempio n. 24
0
        public async Task <List <string> > RetrieveVersions(CreepScore.Region region)
        {
            Url url = UrlConstants.StaticDataUrlBuilder(region, UrlConstants.versionsPart);

            url.SetQueryParams(new
            {
                api_key = apiKey
            });
            Uri uri = new Uri(url.ToString());

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(HelperMethods.LoadStrings(JArray.Parse(responseString)));
        }
Esempio n. 25
0
        public async Task <RealmStatic> RetrieveRealmData(CreepScore.Region region)
        {
            Url url = UrlConstants.StaticDataUrlBuilder(region, UrlConstants.realmPart);

            url.SetQueryParams(new
            {
                api_key = apiKey
            });
            Uri uri = new Uri(url.ToString());

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(LoadRealmData(JObject.Parse(responseString)));
        }
Esempio n. 26
0
        public async Task <CurrentGameInfoLive> RetrieveCurrentGameInfo()
        {
            Url url = new Url(UrlConstants.GetBaseUrl(region)).AppendPathSegments(UrlConstants.observerModeRestpart,
                                                                                  "/consumer/getSpectatorGameInfo/", UrlConstants.GetPlatformId(region), id.ToString());

            url.SetQueryParams(new
            {
                api_key = CreepScore.apiKey
            });
            Uri uri = new Uri(url.ToString());
            await CreepScore.GetPermission(region);

            string responseString;

            try
            {
                responseString = await CreepScore.GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(HelperMethods.LoadCurrentGameInfo(JObject.Parse(responseString)));
        }
Esempio n. 27
0
        public async Task <LanguageStringsStatic> RetrieveLanguageStrings(CreepScore.Region region, string locale = "", string version = "")
        {
            Url url = UrlConstants.StaticDataUrlBuilder(region, UrlConstants.languageStringsPart);

            url.SetQueryParams(new
            {
                locale  = locale,
                version = version,
                api_key = apiKey
            });
            Uri uri = new Uri(url.ToString());

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(HelperMethods.LoadLanguageStringsStatic(JObject.Parse(responseString)));
        }
Esempio n. 28
0
        public async Task <Champion> RetrieveChampion(CreepScore.Region region, int id)
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.championAPIVersion, UrlConstants.championPart).AppendPathSegment(id.ToString());

            url.SetQueryParams(new
            {
                api_key = apiKey
            });
            Uri uri = new Uri(url.ToString());

            await GetPermission(region);

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(LoadChampion(JObject.Parse(responseString)));
        }
Esempio n. 29
0
        public async Task <FeaturedGamesLive> RetrieveFeaturedGames(CreepScore.Region region)
        {
            Url url = new Url(UrlConstants.GetBaseUrl(region)).AppendPathSegments(UrlConstants.observerModeRestpart,
                                                                                  "/featured");

            url.SetQueryParams(new
            {
                api_key = apiKey
            });
            Uri uri = new Uri(url.ToString());
            await CreepScore.GetPermission(region);

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(LoadFeaturedGames(JObject.Parse(responseString)));
        }
Esempio n. 30
0
        static ResourceManager()
        {
            CatalogApi.Settings.File constants;
            bool        fileExists = false;
            XmlDocument xmlDoc;
            string      json = string.Empty;

            if (ConfigurationManager.AppSettings.Keys.Cast <string>().Contains("UpdateDirectory") == true)
            {
                UpdateDirectory = ConfigurationManager.AppSettings["UpdateDirectory"]; // "Temp"
            }
            else
            {
                ;
            }

            if (ConfigurationManager.AppSettings.Keys.Cast <string>().Contains("ResourceDirectory") == true)
            {
                ResourceFolder = ConfigurationManager.AppSettings["ResourceDirectory"];
            }
            else
            {
                ;
            }

            if (ConfigurationManager.AppSettings.Keys.Cast <string>().Contains("UpdateFileArchive") == true)
            {
                UpdateFileArchive = new CatalogApi.Settings.File(ConfigurationManager.AppSettings["UpdateFileArchive"]).Name;
            }
            else
            {
                ;
            }

            if (ConfigurationManager.AppSettings.Keys.Cast <string>().Contains("CatalogConstants") == true)
            {
                constants = new CatalogApi.Settings.File(ConfigurationManager.AppSettings["CatalogConstants"]);
                switch (constants.Type)
                {
                case File.TYPE.JSON:
                    json = CodeTools.Helpers.IoHelper.OpenFile(constants.Name, out fileExists);
                    if (fileExists == true)
                    {
                        Catalogs = new CatalogConstants(json);
                    }
                    else
                    {
                        Catalogs = new CatalogConstants();
                        CodeTools.Helpers.IoHelper.SaveToFile(Catalogs.GetJsonValue(), constants.Name);
                    }
                    break;

                case File.TYPE.XML:
                    xmlDoc = new XmlDocument();
                    xmlDoc.Load(constants.Name);
                    Catalogs = new CatalogConstants(xmlDoc);
                    break;

                default:
                    break;
                }
            }
            else
            {
                Catalogs = new CatalogConstants();
            }


            if (ConfigurationManager.AppSettings.Keys.Cast <string>().Contains("UrlConstants") == true)
            {
                constants = new CatalogApi.Settings.File(ConfigurationManager.AppSettings["UrlConstants"]);
                switch (constants.Type)
                {
                case File.TYPE.JSON:
                    json = CodeTools.Helpers.IoHelper.OpenFile(constants.Name, out fileExists);
                    if (fileExists == true)
                    {
                        Urls = new UrlConstants(json);
                    }
                    else
                    {
                        Urls = new UrlConstants();
                        CodeTools.Helpers.IoHelper.SaveToFile(Urls.GetJsonValue(), constants.Name);
                    }
                    break;

                case File.TYPE.XML:
                    xmlDoc = new XmlDocument();
                    xmlDoc.Load(constants.Name);
                    Urls = new UrlConstants(xmlDoc);
                    break;

                default:
                    break;
                }
            }
            else
            {
                Catalogs = new CatalogConstants();
            }

            Prepare();
        }