Skip to content

codingame_tools.client.service.services.notification

notification

Async Notification service endpoint.

CgNotificationServiceHelper

CgNotificationServiceHelper(service)

Bases: CgServiceHelper['CgNotificationService']

Helper methods for CgNotificationService. Currently empty.

Source code in codingame_tools/client/service/cg_service.py
124
125
def __init__(self, service: TService) -> None:
    self.service = service

CgNotificationService

CgNotificationService(client)

Bases: CgService

Async Notification service endpoint.

Source code in codingame_tools/client/service/services/notification.py
26
27
28
def __init__(self, client: CgClient) -> None:
    super().__init__(client, "Notification")
    self.helper = CgNotificationServiceHelper(self)

find_unread_notifications async

find_unread_notifications(codingamer_id=None)

Find unread notifications for a codingamer.

This endpoint always requires a valid login, regardless of whose notifications are being queried.

Parameters:

  • codingamer_id (int | None, default: None ) –

    The codingamer to find unread notifications for. If not provided, defaults to the logged-in codingamer's ID.

Returns:

  • list[CgNotification]

    A list of CgNotification objects, most recent first.

Raises:

  • CgAuthenticationError

    If the session is not authenticated and cannot implicitly login, or if codingamer_id is not provided and no codingamer ID can be resolved from the session's credentials.

  • CgClientHttpError

    If a transport error occurs, if the response content could not be decoded at all, if the status code is not 2xx, or if the decoded content is not a list.

Source code in codingame_tools/client/service/services/notification.py
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
async def find_unread_notifications(
            self,
            codingamer_id: int | None = None,
        ) -> list[CgNotification]:
    """Find unread notifications for a codingamer.

       This endpoint always requires a valid login, regardless of whose notifications are
       being queried.

    Args:
        codingamer_id: The codingamer to find unread notifications for. If not provided,
                       defaults to the logged-in codingamer's ID.

    Returns:
        A list of CgNotification objects, most recent first.

    Raises:
        CgAuthenticationError:
            If the session is not authenticated and cannot implicitly login, or if
            `codingamer_id` is not provided and no codingamer ID can be resolved from the
            session's credentials.
        CgClientHttpError:
            If a transport error occurs, if the response content could not be decoded at all,
            if the status code is not 2xx, or if the decoded content is not a list.
    """
    await self.require_authenticate()
    if codingamer_id is None:
        codingamer_id = self.client.codingamer_id
        if codingamer_id is None:
            raise CgAuthenticationError()
    raw_notifications = await self.service_request_to_list(
            "findUnreadNotifications", [codingamer_id])
    return CgNotification.from_list(cast(list[JsonDict], raw_notifications))