Skip to content

Commit

Permalink
OfficialAPI: add river race and river race log endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
gogaz committed Nov 1, 2020
1 parent 09ff7fe commit 5931a57
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog
All notable changes to this project will be documented in this file.

## 15/09/2020

### Added
- OfficialAPI: Added `get_clan_river_race` and `get_clan_river_race_log`

## 09/11/2019

### Fixed
Expand Down
39 changes: 28 additions & 11 deletions clashroyale/official_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def get_player(self, tag: crtag, timeout=None):
Parameters
----------
tag: str
A valid tournament tag. Minimum length: 3
A valid player tag. Minimum length: 3
Valid characters: 0289PYLQGRJCUV
timeout: Optional[int] = None
Custom timeout that overwrites Client.timeout
Expand All @@ -263,7 +263,7 @@ def get_player_verify(self, tag: crtag, apikey: str, timeout=None):
Parameters
----------
tag: str
A valid tournament tag. Minimum length: 3
A valid player tag. Minimum length: 3
Valid characters: 0289PYLQGRJCUV
apikey: str
The API Key in the player's settings
Expand All @@ -280,7 +280,7 @@ def get_player_battles(self, tag: crtag, **params: keys):
Parameters
----------
tag: str
A valid tournament tag. Minimum length: 3
A valid player tag. Minimum length: 3
Valid characters: 0289PYLQGRJCUV
\*\*limit: Optional[int] = None
Limit the number of items returned in the response
Expand All @@ -297,7 +297,7 @@ def get_player_chests(self, tag: crtag, timeout: int=None):
Parameters
----------
tag: str
A valid tournament tag. Minimum length: 3
A valid player tag. Minimum length: 3
Valid characters: 0289PYLQGRJCUV
timeout: Optional[int] = None
Custom timeout that overwrites Client.timeout
Expand All @@ -312,7 +312,7 @@ def get_clan(self, tag: crtag, timeout: int=None):
Parameters
----------
tag: str
A valid tournament tag. Minimum length: 3
A valid clan tag. Minimum length: 3
Valid characters: 0289PYLQGRJCUV
timeout: Optional[int] = None
Custom timeout that overwrites Client.timeout
Expand Down Expand Up @@ -350,18 +350,18 @@ def search_clans(self, **params: clansearch):
return self._get_model(url, PartialClan, **params)

@typecasted
def get_clan_war(self, tag: crtag, timeout: int=None):
"""Get inforamtion about a clan's current clan war
def get_clan_river_race(self, tag: crtag, timeout: int = None):
"""Get inforamtion about a clan's current river race
Parameters
----------
tag: str
A valid tournament tag. Minimum length: 3
A valid clan tag. Minimum length: 3
Valid characters: 0289PYLQGRJCUV
timeout: Optional[int] = None
Custom timeout that overwrites Client.timeout
"""
url = self.api.CLAN + '/' + tag + '/currentwar'
url = self.api.CLAN + '/' + tag + '/currentriverrace'
return self._get_model(url, timeout=timeout)

@typecasted
Expand All @@ -371,7 +371,7 @@ def get_clan_members(self, tag: crtag, **params: keys):
Parameters
----------
tag: str
A valid tournament tag. Minimum length: 3
A valid clan tag. Minimum length: 3
Valid characters: 0289PYLQGRJCUV
\*\*limit: Optional[int] = None
Limit the number of items returned in the response
Expand All @@ -388,7 +388,7 @@ def get_clan_war_log(self, tag: crtag, **params: keys):
Parameters
----------
tag: str
A valid tournament tag. Minimum length: 3
A valid clan tag. Minimum length: 3
Valid characters: 0289PYLQGRJCUV
\*\*limit: Optional[int] = None
Limit the number of items returned in the response
Expand All @@ -398,6 +398,23 @@ def get_clan_war_log(self, tag: crtag, **params: keys):
url = self.api.CLAN + '/' + tag + '/warlog'
return self._get_model(url, **params)

@typecasted
def get_clan_river_race_log(self, tag: crtag, **params: keys):
"""Get a clan's river race log
Parameters
----------
tag: str
A valid clan tag. Minimum length: 3
Valid characters: 0289PYLQGRJCUV
\*\*limit: Optional[int] = None
Limit the number of items returned in the response
\*\*timeout: Optional[int] = None
Custom timeout that overwrites Client.timeout
"""
url = self.api.CLAN + '/' + tag + '/riverracelog'
return self._get_model(url, **params)

@typecasted
def get_tournament(self, tag: crtag, timeout=0):
"""Get a tournament information
Expand Down
8 changes: 6 additions & 2 deletions tests/official_api/test_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ async def test_search_clans_all_data(self):
await clans.all_data()
self.assertGreater(len(clans), 3)

async def test_get_clan_war(self):
clan = await self.cr.get_clan_war(self.clan_tags[0])
async def test_get_clan_river_race(self):
clan = await self.cr.get_clan_river_race(self.clan_tags[0])
self.assertTrue(isinstance(clan.state, str))

async def test_get_clan_war_timeout(self):
Expand All @@ -99,6 +99,10 @@ async def test_get_clan_war_log(self):
clan = await self.cr.get_clan_war_log(self.clan_tags[0])
self.assertTrue(isinstance(clan, clashroyale.official_api.PaginatedAttrDict))

async def test_get_clan_river_race_log(self):
clan = await self.cr.get_clan_river_race_log(self.clan_tags[0])
self.assertTrue(isinstance(clan, clashroyale.official_api.PaginatedAttrDict))

async def test_get_clan_war_log_timeout(self):
clan = await self.cr.get_clan_war_log(self.clan_tags[1], timeout=100)
self.assertTrue(isinstance(clan, clashroyale.official_api.PaginatedAttrDict))
Expand Down
8 changes: 6 additions & 2 deletions tests/official_api/test_blocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def test_search_clans_all_data(self):
clans.all_data()
self.assertGreater(len(clans), 3)

def test_get_clan_war(self):
clan = self.cr.get_clan_war(self.clan_tags[0])
def test_get_clan_river_race(self):
clan = self.cr.get_clan_river_race(self.clan_tags[0])
self.assertTrue(isinstance(clan.state, str))

def test_get_clan_war_timeout(self):
Expand All @@ -102,6 +102,10 @@ def test_get_clan_war_log(self):
clan = self.cr.get_clan_war_log(self.clan_tags[0])
self.assertTrue(isinstance(clan, clashroyale.official_api.PaginatedAttrDict))

def test_get_clan_river_race_log(self):
clan = self.cr.get_clan_river_race_log(self.clan_tags[0])
self.assertTrue(isinstance(clan, clashroyale.official_api.PaginatedAttrDict))

def test_get_clan_war_log_timeout(self):
clan = self.cr.get_clan_war_log(self.clan_tags[1], timeout=100)
self.assertTrue(isinstance(clan, clashroyale.official_api.PaginatedAttrDict))
Expand Down

0 comments on commit 5931a57

Please sign in to comment.