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 Sep 18, 2020
1 parent 3184c74 commit 9eea1d4
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 9 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`

## 06/11/2019

### Fixed
Expand Down
50 changes: 41 additions & 9 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 @@ -356,22 +356,37 @@ def get_clan_war(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
"""
url = self.api.CLAN + '/' + tag + '/currentwar'
return self._get_model(url, timeout=timeout)

@typecasted
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 clan tag. Minimum length: 3
Valid characters: 0289PYLQGRJCUV
timeout: Optional[int] = None
Custom timeout that overwrites Client.timeout
"""
url = self.api.CLAN + '/' + tag + '/currentriverrace'
return self._get_model(url, timeout=timeout)

@typecasted
def get_clan_members(self, tag: crtag, **params: keys):
"""Get the clan's members
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,14 +403,31 @@ 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
\*\*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_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 + '/warlog'
url = self.api.CLAN + '/' + tag + '/riverracelog'
return self._get_model(url, **params)

@typecasted
Expand Down
8 changes: 8 additions & 0 deletions tests/official_api/test_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ async def test_get_clan_war(self):
clan = await self.cr.get_clan_war(self.clan_tags[0])
self.assertTrue(isinstance(clan.state, str))

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):
clan = await self.cr.get_clan_war(self.clan_tags[1], timeout=100)
self.assertTrue(isinstance(clan.state, str))
Expand All @@ -99,6 +103,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: 8 additions & 0 deletions tests/official_api/test_blocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def test_get_clan_war(self):
clan = self.cr.get_clan_war(self.clan_tags[0])
self.assertTrue(isinstance(clan.state, str))

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):
clan = self.cr.get_clan_war(self.clan_tags[1], timeout=100)
self.assertTrue(isinstance(clan.state, str))
Expand All @@ -102,6 +106,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 9eea1d4

Please sign in to comment.