Bases: RequestModel
, ClanWar
Retrieve information about clan's current clan war
Source code in pyclasher/api/requests/clan_current_war.py
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 | class ClanCurrentWarRequest(RequestModel, ClanWar):
"""
Retrieve information about clan's current clan war
"""
clan_tag = None
def __init__(self, clan_tag):
"""
initialisation of the clan current war request
:param clan_tag: Tag of the clan.
:type clan_tag: str
"""
self.clan_tag = clan_tag
RequestModel.__init__(self,
"clans/{clan_tag}/currentwar",
clan_tag=self.clan_tag)
ClanWar.__init__(self, None)
return
@classmethod
async def from_base_clan(cls, base_clan):
"""
method that returns the clan object of a BaseClan or a BaseClan subclass model
:param base_clan: The BaseClan or a BaseClan subclass model
:type base_clan: BaseClan
:return: returns a ClanCurrentWarRequest object
:rtype: ClanCurrentWarRequest
"""
self = await cls(base_clan.tag).request()
return self
async def request(self, client_id=None):
await super().request(client_id)
if (self.state == ClanWarState.IN_WAR
or self.state == ClanWarState.WAR
or self.state == ClanWarState.PREPARATION
or self.state == ClanWarState.ENDED
):
self._data['clan']['members'] = sorted(
self._data['clan']['members'],
key=lambda member: member['mapPosition']
)
self._data['opponent']['members'] = sorted(
self._data['opponent']['members'],
key=lambda member: member['mapPosition']
)
|
__init__(clan_tag)
initialisation of the clan current war request
:param clan_tag: Tag of the clan.
:type clan_tag: str
Source code in pyclasher/api/requests/clan_current_war.py
11
12
13
14
15
16
17
18
19
20
21
22
23 | def __init__(self, clan_tag):
"""
initialisation of the clan current war request
:param clan_tag: Tag of the clan.
:type clan_tag: str
"""
self.clan_tag = clan_tag
RequestModel.__init__(self,
"clans/{clan_tag}/currentwar",
clan_tag=self.clan_tag)
ClanWar.__init__(self, None)
return
|
from_base_clan(base_clan)
async
classmethod
method that returns the clan object of a BaseClan or a BaseClan subclass model
:param base_clan: The BaseClan or a BaseClan subclass model
:type base_clan: BaseClan
:return: returns a ClanCurrentWarRequest object
:rtype: ClanCurrentWarRequest
Source code in pyclasher/api/requests/clan_current_war.py
25
26
27
28
29
30
31
32
33
34
35 | @classmethod
async def from_base_clan(cls, base_clan):
"""
method that returns the clan object of a BaseClan or a BaseClan subclass model
:param base_clan: The BaseClan or a BaseClan subclass model
:type base_clan: BaseClan
:return: returns a ClanCurrentWarRequest object
:rtype: ClanCurrentWarRequest
"""
self = await cls(base_clan.tag).request()
return self
|