@@ -196,7 +196,7 @@ def _get_model(self, url, model, key=None):
196196 # Calls the async function
197197 return self ._aget_model (url , model = model , key = key )
198198
199- data , resp = self ._request (url )
199+ data = self ._request (url )
200200 if self .prevent_ratelimit :
201201 time .sleep (1 / self .ratelimit [0 ])
202202
@@ -259,45 +259,74 @@ def get_club_members(self, tag: bstag):
259259 url = '{}/{}/members' .format (self .api .CLUB , tag )
260260 return self ._get_model (url , model = Members )
261261
262- def get_rankings (self , ranking_type : str , limit : int = 200 , region = 'global' , brawler = None ):
262+ def get_player_rankings (self , limit = 200 , region = 'global' ):
263263 """
264- Get the top count players/clubs/brawlers .
264+ Get the top players.
265265
266266 Parameters
267267 ----------
268- ranking_type: str
269- The type of ranking. Must be "players", "clubs", "brawlers".
270- Anything else will return a ValueError.
271268 limit: Optional[int] = 200
272269 The number of top players or clubs to fetch.
273- If count > 200, it will return a ValueError .
270+ If count > 200, it will set the limit to 200 .
274271 region: Optional[str] = "global"
275272 The region to retrieve from. Must be a 2 letter country code or "global".
276- brawler: Optional[Union[str, int]] = None
277- The brawler name or ID.
278273
279274 Returns Ranking
280275 """
281- if brawler :
282- brawler = brawler .lower ()
283- if brawler not in self .api .BRAWLERS :
284- raise ValueError ('Invalid brawler.' )
285-
286- # Check for invalid parameters
287- if ranking_type not in ('players' , 'clubs' , 'brawlers' ):
288- raise ValueError ("'lb_type' must be 'players', 'clubs' or 'brawlers'." )
289276 if not 0 < limit <= 200 :
290- raise ValueError ('Make sure limit is between 1 and 200.' )
277+ limit = 200
278+
279+ url = '{}/{}/players?limit={}' .format (self .api .RANKINGS , region , limit )
280+ return self ._get_model (url , model = Ranking )
281+
282+ def get_club_rankings (self , limit = 200 , region = 'global' ):
283+ """
284+ Get the top clubs.
285+
286+ Parameters
287+ ----------
288+ limit: Optional[int] = 200
289+ The number of top players or clubs to fetch.
290+ If count > 200, it will set the limit to 200.
291+ region: Optional[str] = "global"
292+ The region to retrieve from. Must be a 2 letter country code or "global".
293+
294+ Returns Ranking
295+ """
296+ if not 0 < limit <= 200 :
297+ limit = 200
298+
299+ url = '{}/{}/clubs?limit={}' .format (self .api .RANKINGS , region , limit )
300+ return self ._get_model (url , model = Ranking )
301+
302+ def get_brawler_rankings (self , brawler , limit = 200 , region = 'global' ):
303+ """
304+ Get the leaderboard for a certain brawler.
305+
306+ Parameters
307+ ----------
308+ brawler: Union[str, int]
309+ The brawler name or ID
310+ limit: Optional[int] = 200
311+ The number of top players or clubs to fetch.
312+ If count > 200, it will set the limit to 200.
313+ region: Optional[str] = "global"
314+ The region to retrieve from. Must be a 2 letter country code or "global".
315+
316+ Returns Ranking
317+ """
318+ brawler = brawler .lower ()
319+ if brawler not in self .api .BRAWLERS :
320+ raise ValueError ('Invalid brawler.' )
321+
322+ if not 0 < limit <= 200 :
323+ limit = 200
291324
292325 # Replace brawler name with ID
293326 if brawler in self .api .BRAWLERS .keys ():
294327 brawler = self .api .BRAWLERS [brawler ]
295328
296- # Construct URL
297- url = '{}/{}/{}?limit={}' .format (self .api .RANKINGS , region , ranking_type , limit )
298- if ranking_type == 'brawlers' :
299- url = '{}/{}/{}/{}?limit={}' .format (self .api .RANKINGS , region , ranking_type , brawler , limit )
300-
329+ url = '{}/{}/brawlers/{}?limit={}' .format (self .api .RANKINGS , region , brawler , limit )
301330 return self ._get_model (url , model = Ranking )
302331
303332 @typecasted
0 commit comments