Skip to content

Account

Represents a Riot account.

Source code in nexar/models/account.py
@dataclass(frozen=True)
class RiotAccount:
    """Represents a Riot account."""

    puuid: str
    """
    Player Universally Unique Identifier.

    Check out docs/puuid.md for more.
    """

    game_name: str
    """
    Game name associated with Riot account, if a name is set.

    ```
    bexli#bex
    ^^^^^
    ```
    """

    tag_line: str
    """
    Tag line associated with Riot account, if a tag line is set.

    ```
    bexli#bex
          ^^^
    ```
    """

    @classmethod
    def from_api_response(cls, data: dict[str, Any]) -> "RiotAccount":
        """Create RiotAccount from API response."""
        return cls(
            puuid=data["puuid"],
            game_name=data["gameName"],
            tag_line=data["tagLine"],
        )

game_name instance-attribute

Game name associated with Riot account, if a name is set.

bexli#bex
^^^^^

puuid instance-attribute

Player Universally Unique Identifier.

Check out docs/puuid.md for more.

tag_line instance-attribute

Tag line associated with Riot account, if a tag line is set.

bexli#bex
      ^^^

from_api_response(data) classmethod

Create RiotAccount from API response.

Source code in nexar/models/account.py
@classmethod
def from_api_response(cls, data: dict[str, Any]) -> "RiotAccount":
    """Create RiotAccount from API response."""
    return cls(
        puuid=data["puuid"],
        game_name=data["gameName"],
        tag_line=data["tagLine"],
    )

Represents a League of Legends summoner.

Source code in nexar/models/account.py
@dataclass(frozen=True)
class Summoner:
    """Represents a League of Legends summoner."""

    id: str | None
    """(Deprecated) Summoner ID."""

    puuid: str
    """
    Player Universally Unique Identifier.

    Check out docs/puuid.md for more.
    """

    profile_icon_id: int
    """ID of the summoner icon associated with the summoner."""

    @property
    def profile_icon_url(self) -> str:
        """Link to profile icon URL via CDragon."""
        return (
            f"https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/"
            f"global/default/v1/profile-icons/{self.profile_icon_id}.jpg"
        )

    revision_date: datetime
    """
    Date summoner was last modified specified as datetime.

    The following events will update this timestamp:
        - profile icon change
        - playing the tutorial or advanced tutorial
        - finishing a game
        - summoner name change
    """

    summoner_level: int
    """Summoner level associated with the summoner."""

    @classmethod
    def from_api_response(cls, data: dict[str, Any]) -> "Summoner":
        """Create Summoner from API response."""
        return cls(
            id=data.get("id"),
            puuid=data["puuid"],
            profile_icon_id=data["profileIconId"],
            revision_date=datetime.fromtimestamp(data["revisionDate"] / 1000, tz=UTC),
            summoner_level=data["summonerLevel"],
        )

id instance-attribute

(Deprecated) Summoner ID.

profile_icon_id instance-attribute

ID of the summoner icon associated with the summoner.

profile_icon_url property

Link to profile icon URL via CDragon.

puuid instance-attribute

Player Universally Unique Identifier.

Check out docs/puuid.md for more.

revision_date instance-attribute

Date summoner was last modified specified as datetime.

The following events will update this timestamp
  • profile icon change
  • playing the tutorial or advanced tutorial
  • finishing a game
  • summoner name change

summoner_level instance-attribute

Summoner level associated with the summoner.

from_api_response(data) classmethod

Create Summoner from API response.

Source code in nexar/models/account.py
@classmethod
def from_api_response(cls, data: dict[str, Any]) -> "Summoner":
    """Create Summoner from API response."""
    return cls(
        id=data.get("id"),
        puuid=data["puuid"],
        profile_icon_id=data["profileIconId"],
        revision_date=datetime.fromtimestamp(data["revisionDate"] / 1000, tz=UTC),
        summoner_level=data["summonerLevel"],
    )