|
46 | 46 |
|
47 | 47 |
|
48 | 48 | class PartialUser: |
| 49 | + """ |
| 50 | + A class that contains minimal data about a user from the API. |
| 51 | +
|
| 52 | + Attributes |
| 53 | + ----------- |
| 54 | + id: :class:`int` |
| 55 | + The user's ID. |
| 56 | + name: Optional[:class:`str`] |
| 57 | + The user's name. In most cases, this is provided. There are however, rare cases where it is not. |
| 58 | + """ |
49 | 59 |
|
50 | 60 | __slots__ = "id", "name", "_http", "_cached_rewards" |
51 | 61 |
|
@@ -1492,6 +1502,44 @@ def __init__(self, http: "TwitchHTTP", data: dict): |
1492 | 1502 |
|
1493 | 1503 |
|
1494 | 1504 | class User(PartialUser): |
| 1505 | + """ |
| 1506 | + A full user object, containing data from the users endpoint. |
| 1507 | +
|
| 1508 | + Attributes |
| 1509 | + ----------- |
| 1510 | + id: :class:`int` |
| 1511 | + The user's ID |
| 1512 | + name: :class:`str` |
| 1513 | + The user's login name |
| 1514 | + display_name: :class:`str` |
| 1515 | + The name that is displayed in twitch chat. For the most part, this is simply a change of capitalization |
| 1516 | + type: :class:`~twitchio.UserTypeEnum` |
| 1517 | + The user's type. This will normally be :class:`~twitchio.UserTypeEnum.none`, unless they are twitch staff or admin |
| 1518 | + broadcaster_type: :class:`~twitchio.BroadcasterTypeEnum` |
| 1519 | + What type of broacaster the user is. none, affiliate, or partner |
| 1520 | + description: :class:`str` |
| 1521 | + The user's bio |
| 1522 | + profile_image: :class:`str` |
| 1523 | + The user's profile image URL |
| 1524 | + offline_image: :class:`str` |
| 1525 | + The user's offline image splash URL |
| 1526 | + view_count: Tuple[int] |
| 1527 | + The amount of views this channel has |
| 1528 | +
|
| 1529 | + .. warning:: |
| 1530 | +
|
| 1531 | + This field has been deprecated by twitch, and is no longer updated. |
| 1532 | + See `here <https://discuss.dev.twitch.tv/t/get-users-api-endpoint-view-count-deprecation/37777>`_ for more information. |
| 1533 | +
|
| 1534 | + .. note:: |
| 1535 | +
|
| 1536 | + This field is a tuple due to a mistake when creating the models. |
| 1537 | + Due to semver principals, this cannot be fixed until version 3.0 (at which time we will be removing the field entirely). |
| 1538 | + created_at: :class:`datetime.datetime` |
| 1539 | + When the user created their account |
| 1540 | + email: Optional[class:`str`] |
| 1541 | + The user's email. This is only returned if you have the ``user:read:email`` scope on the token used to make the request |
| 1542 | + """ |
1495 | 1543 |
|
1496 | 1544 | __slots__ = ( |
1497 | 1545 | "_http", |
@@ -1519,7 +1567,7 @@ def __init__(self, http: "TwitchHTTP", data: dict): |
1519 | 1567 | self.description: str = data["description"] |
1520 | 1568 | self.profile_image: str = data["profile_image_url"] |
1521 | 1569 | self.offline_image: str = data["offline_image_url"] |
1522 | | - self.view_count: Tuple[int] = (data["view_count"],) # this isn't supposed to be a tuple but too late to fix it! |
| 1570 | + self.view_count: Tuple[int] = (data.get("view_count", 0),) # this isn't supposed to be a tuple but too late to fix it! |
1523 | 1571 | self.created_at = parse_timestamp(data["created_at"]) |
1524 | 1572 | self.email: Optional[str] = data.get("email") |
1525 | 1573 | self._cached_rewards = None |
|
0 commit comments