1"""Routes of the Guild API."""
2
3from urllib.parse import quote
4
5from wow._async._resource import AsyncResource
6from wow.models.guild import Guild, GuildRoster
7
8__all__ = ["AsyncGuilds"]
9
10
11def _path(slug: str, document: str = "") -> str:
12 return f"/data/wow/guild/{quote(slug.lower(), safe='')}{document}"
13
14
[docs]
15class AsyncGuilds(AsyncResource):
16 """``client.guilds``: any guild and its roster. An app token is enough.
17
18 Each method takes the guild's slug, such as ``sidequest``: its name in lowercase, with spaces as hyphens.
19 """
20
21 __slots__ = ()
22
[docs]
23 async def get(self, slug: str) -> Guild:
24 """Get a guild's faction, ruleset and size."""
25 return await self._get("profile", _path(slug), Guild)
26
[docs]
27 async def roster(self, slug: str) -> GuildRoster:
28 """Get every member of a guild, with their rank, level, class and race."""
29 return await self._get("profile", _path(slug, "/roster"), GuildRoster)