1"""Models for the Account Profile API.
2
3Blizzard has not announced or documented a Forever profile API. This shape comes from community probing
4(https://mhuijskens.com/WoWForever/Api/), not from a recorded live response: it needs a user token this package
5cannot obtain on its own.
6"""
7
8import re
9
10from wow.models._common import Document, IdName, Link, Model, Ref, TypedName
11
12__all__ = ["AccountCharacter", "AccountProfile", "WowAccount"]
13
14_PROTECTED_CHARACTER_RE = re.compile(r"/protected-character/(\d+)-\d+(?:[?/]|$)")
15
16
[docs]
17class AccountCharacter(Model):
18 """One character on a WoW Forever account.
19
20 Shape from community probing; Blizzard has not documented it. Forever characters carry a ``surname`` alongside
21 their first ``name``, and omit the ``realm`` field retail and Classic characters have; the realm only shows up
22 in :attr:`protected_character`'s link, which :attr:`realm_id` parses.
23 """
24
25 character: Link
26 protected_character: Link
27 name: str
28 surname: str
29 id: int
30 playable_class: IdName
31 playable_race: IdName
32 gender: TypedName
33 faction: TypedName
34 level: int
35 realm: Ref | None = None
36
37 @property
38 def realm_id(self) -> int | None:
39 """The realm id parsed from :attr:`protected_character`'s link, or ``None`` if it cannot be parsed."""
40 match = _PROTECTED_CHARACTER_RE.search(self.protected_character.href)
41 return int(match.group(1)) if match else None
42
43
[docs]
44class WowAccount(Model):
45 """One Battle.net account's WoW Forever characters.
46
47 Shape from community probing; Blizzard has not documented it.
48 """
49
50 id: int
51 characters: tuple[AccountCharacter, ...]
52
53
[docs]
54class AccountProfile(Document):
55 """The authenticated user's account profile: every linked account's Forever characters.
56
57 Shape from community probing; Blizzard has not documented it.
58 """
59
60 wow_accounts: tuple[WowAccount, ...]