Skip to content

user

numerous.session.user

Module for handling user-related functionality.

User dataclass

Represents a Numerous platform user.

Attributes:

Name Type Description
id str

The unique identifier for the user.

name str

The full name of the user.

email str | None

The email of the user.

Source code in numerous/session/user.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
@dataclass
class User:
    """
    Represents a Numerous platform user.

    Attributes:
        id (str): The unique identifier for the user.
        name (str): The full name of the user.
        email (str | None): The email of the user.

    """

    id: str
    name: str
    email: str | None = None
    _client: Client | None = None

    @property
    def collection(self) -> CollectionReference:
        """
        A user's collection.

        A collection scoped for the current user. It is a child-collection of the
        root collection with the key "users", and has the user's ID as key.

        Equivalent to:
        >>> collection("users").collection(user.id)

        Returns:
            The collection for this user.

        """
        return collection("users", self._client).collection(self.id)

    @staticmethod
    def from_user_info(
        user_info: dict[str, Any], _client: Client | None = None
    ) -> User:
        """
        Create a User instance from a dictionary of user information.

        Args:
            user_info: A dictionary containing user information.

        Returns:
            A new User instance created from the provided information.

        """
        return User(
            id=user_info["user_id"],
            name=user_info["user_full_name"],
            email=user_info.get("user_email"),
            _client=_client,
        )

collection: CollectionReference property

A user's collection.

A collection scoped for the current user. It is a child-collection of the root collection with the key "users", and has the user's ID as key.

Equivalent to:

collection("users").collection(user.id)

Returns:

Type Description
CollectionReference

The collection for this user.

from_user_info(user_info, _client=None) staticmethod

Create a User instance from a dictionary of user information.

Parameters:

Name Type Description Default
user_info dict[str, Any]

A dictionary containing user information.

required

Returns:

Type Description
User

A new User instance created from the provided information.

Source code in numerous/session/user.py
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
@staticmethod
def from_user_info(
    user_info: dict[str, Any], _client: Client | None = None
) -> User:
    """
    Create a User instance from a dictionary of user information.

    Args:
        user_info: A dictionary containing user information.

    Returns:
        A new User instance created from the provided information.

    """
    return User(
        id=user_info["user_id"],
        name=user_info["user_full_name"],
        email=user_info.get("user_email"),
        _client=_client,
    )