taycaldwell / riot-api-java

Riot Games API Java Library
http://taycaldwell.github.io/riot-api-java/
Apache License 2.0
192 stars 73 forks source link

getLeagueBySummoner() - getEntries issue #66

Closed fima-taf closed 8 years ago

fima-taf commented 8 years ago

Hi again!

I'm trying to get the summoner's league division, but i am getting many version of the division. When i run the request on Riot's Web https://euw.api.pvp.net/api/lol/euw/v2.5/league/by-summoner/62128873, 19881488/entry?api_key=<API-KEY> I am getting the following json: {"62128873": [{ "queue": "RANKED_SOLO_5x5", "name": "Kennen's Pyromancers", "entries": [{ "leaguePoints": 31, "isFreshBlood": false, "isHotStreak": false, "division": "V", "isInactive": false, "isVeteran": false, "losses": 63, "playerOrTeamName": "vBandiTv", "playerOrTeamId": "62128873", "wins": 40 }], "tier": "BRONZE" }]}

The devision in the above json is right, but when i try to get the division from Java, I am using the following method: String lDivision = api.getLeagueBySummoner(Region.EUW, api.getSummonerByName(sName).getId()).get(0).getEntries().get(0).getDivision()

The problem is that this method returns a wrong division, and when i run .size() on the .getEntries() i get a size of 100, but on the json above the "entries" list have only 10 objects.

Is that some problem with the method? Or am I doing something wrong?

Thx in advance again!

taycaldwell commented 8 years ago

Hi,

Please don't include your API key in your examples. I went ahead and edited your post to remove it, so no one takes it and uses it for themselves. Looking into your issue now. Just out of curiosity, which version of the library are you currently using?

fima-taf commented 8 years ago

First of all thank you and sorry for the key things, i didn't even noticed that the url I'v copied has my key, thank you very much, i appreciate that!

The version of current library i have is 3.9.0.

taycaldwell commented 8 years ago

Hi vBandiTv,

The Riot Games API has two different League endpoints.

One to get the entire league of a summoner (includes entries of the other 99 summoners in that same league):

https://euw.api.pvp.net/api/lol/euw/v2.5/league/by-summoner/62128873,%2019881488?api_key=

The library method that uses this endpoint is getLeagueBySummoners().

and one just to get the league entry of a summoner, (only includes the summoners specified):

https://euw.api.pvp.net/api/lol/euw/v2.5/league/by-summoner/62128873,%2019881488/entry?api_key=

The library method that uses this endpoint is getLeagueEntryBySummoners().

The reason you're getting the wrong division is you're using the method to get all the summoners in the same League as the summoners provided, and looking at the first entry of that list, which will likely be the data for a random summoner rather than the one you wanted.

TLDR: Based on the URL given in your example, I believe you want to use the method getLeagueEntryBySummoners() rather than getLeagueBySummoners().

Kind of confusing and easy to mix up. I'll think of a way to better clarify things like this for the future.

Hope this helps.

fima-taf commented 8 years ago

Thx again rithms, that was the correct method for me!

One more question (I dont want to create a new issue).

The method getTopChampionMasteries() have an enum PlatformId. What is the difference between the Enum PlatformId and the Enum Region?

taycaldwell commented 8 years ago

From what I understand, Riot's API is powered by a bunch of different underlying systems, owned by different teams. Because of this, there's a bit of inconsistency found between endpoints. Some endpoints expect a Region, some expect a PlatformID.

From what I've heard, PlatformID and Region are different, because it is possible that a region can have multiple PlatformIDs. However, the current the relationship between region and platform ID is one-to-one, so there is essentially no difference between the two at this point in time.

As library designers, we could have abstracted the concept of a PlatformID, and just used the Region enum for all methods, but we decided against this in case the one-to-one mapping between Region and PlatformID changes in the future.

TLDR: They are basically the same thing with different names. Some methods expect a PlatformID, some methods expect a Region.

fima-taf commented 8 years ago

Ye, i saw that this 2 enums are the same, but the explanation about the end points made it clear why.

Anyway I'v found some way to convert them and it works, and if it will be changed on the future it still can be changed.

Thx again rithms!