Skip to content

User

User Schema

User ¤

Bases: BaseModel

Sendou.ink User

Attributes:

Name Type Description
id int

User ID

name str

User Name

discord_id str

Discord ID

url str

User URL

avatar_url Optional[str]

Avatar URL

country Optional[str]

Country

socials UserSocials

Socials

plus_server_tier Optional[PlusTiers]

Plus Server Tier

peak_xp Optional[float]

Peak XP

weapon_pool List[UserWeapon]

Weapon Pool

badges List[Badge]

Badges

Source code in sendou/models/user.py
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
class User(BaseModel):
    """
    Sendou.ink User

    Attributes:
        id (int): User ID
        name (str): User Name
        discord_id (str): Discord ID
        url (str): User URL
        avatar_url (Optional[str]): Avatar URL
        country (Optional[str]): Country
        socials (UserSocials): Socials
        plus_server_tier (Optional[PlusTiers]): Plus Server Tier
        peak_xp (Optional[float]): Peak XP
        weapon_pool (List[UserWeapon]): Weapon Pool
        badges (List[Badge]): Badges
    """
    id: int
    name: str
    discord_id: str
    url: str
    avatar_url: Optional[str]
    country: Optional[str]
    socials: UserSocials
    plus_server_tier: Optional[PlusTiers]
    peak_xp: Optional[float]
    weapon_pool: List[UserWeapon]
    badges: List[Badge]

    def __init__(self, data: dict, request_client: RequestsClient):
        """
        Init
        :param data: Raw data from API
        :type data: dict
        :param request_client: Request Client
        :type request_client: RequestsClient
        """
        super().__init__(data, request_client)
        self.id = data.get("id", 0)
        self.name = str(data.get("name"))
        self.discord_id = str(data.get("discordId"))
        self.url = str(data.get("url"))
        self.avatar_url = data.get("avatarUrl", None)
        self.country = data.get("country", None)
        self.socials = UserSocials(data.get("socials", {}))
        self.plus_server_tier = None
        plus_server_tier = data.get("plusServerTier")
        if plus_server_tier:
            self.plus_server_tier = PlusTiers(plus_server_tier)
        self.peak_xp = data.get("peakXp", None)
        self.weapon_pool = [UserWeapon(weapon) for weapon in data.get("weaponPool", [])]
        self.badges = [Badge(badge) for badge in data.get("badges", [])]

    @staticmethod
    def api_route(**kwargs) -> str:
        """
        Returns API route for the model

        Args:
            user_id (str): User ID

        Returns:
            (str): API Route
        """
        return f"api/user/{kwargs.get('user_id')}"

__init__(data, request_client) ¤

Init :param data: Raw data from API :type data: dict :param request_client: Request Client :type request_client: RequestsClient

Source code in sendou/models/user.py
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
def __init__(self, data: dict, request_client: RequestsClient):
    """
    Init
    :param data: Raw data from API
    :type data: dict
    :param request_client: Request Client
    :type request_client: RequestsClient
    """
    super().__init__(data, request_client)
    self.id = data.get("id", 0)
    self.name = str(data.get("name"))
    self.discord_id = str(data.get("discordId"))
    self.url = str(data.get("url"))
    self.avatar_url = data.get("avatarUrl", None)
    self.country = data.get("country", None)
    self.socials = UserSocials(data.get("socials", {}))
    self.plus_server_tier = None
    plus_server_tier = data.get("plusServerTier")
    if plus_server_tier:
        self.plus_server_tier = PlusTiers(plus_server_tier)
    self.peak_xp = data.get("peakXp", None)
    self.weapon_pool = [UserWeapon(weapon) for weapon in data.get("weaponPool", [])]
    self.badges = [Badge(badge) for badge in data.get("badges", [])]

api_route(**kwargs) staticmethod ¤

Returns API route for the model

Parameters:

Name Type Description Default
user_id str

User ID

required

Returns:

Type Description
str

API Route

Source code in sendou/models/user.py
107
108
109
110
111
112
113
114
115
116
117
118
@staticmethod
def api_route(**kwargs) -> str:
    """
    Returns API route for the model

    Args:
        user_id (str): User ID

    Returns:
        (str): API Route
    """
    return f"api/user/{kwargs.get('user_id')}"

UserSocials ¤

User Socials Accounts

Attributes:

Name Type Description
twitch Optional[str]

Twitch Username

twitter Optional[str]

Twitter Username

battlefy Optional[str]

Battlefy Username

bsky Optional[str]

Bsky Username

Source code in sendou/models/user.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class UserSocials:
    """
    User Socials Accounts

    Attributes:
        twitch (Optional[str]): Twitch Username
        twitter (Optional[str]): Twitter Username
        battlefy (Optional[str]): Battlefy Username
        bsky (Optional[str]): Bsky Username
    """
    twitch: Optional[str]
    twitter: Optional[str]
    battlefy: Optional[str]
    bsky: Optional[str]

    def __init__(self, data: dict):
        self.twitch = data.get("twitch")
        self.twitter = data.get("twitter")
        self.battlefy = data.get("battlefy")
        self.bsky = data.get("bsky")

UserWeapon ¤

User Weapon in Weapon pool

Attributes:

Name Type Description
id str

Weapon ID

name str

Weapon Name

is_five_star bool

Is Five Star Weapon

Source code in sendou/models/user.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
class UserWeapon:
    """
    User Weapon in Weapon pool

    Attributes:
        id (str): Weapon ID
        name (str): Weapon Name
        is_five_star (bool): Is Five Star Weapon
    """
    id: str
    name: str
    is_five_star: bool

    def __init__(self, data: dict):
        self.id = str(data.get("id"))
        self.name = str(data.get("name"))
        self.is_five_star = bool(data.get("isFiveStar"))