Skip to content

codingame_tools.client.service.services.last_activities

last_activities

Async LastActivities service endpoint.

CgLastActivitiesServiceHelper

CgLastActivitiesServiceHelper(service)

Bases: CgServiceHelper['CgLastActivitiesService']

Helper methods for CgLastActivitiesService. Currently empty.

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

CgLastActivitiesService

CgLastActivitiesService(client)

Bases: CgService

Async LastActivities service endpoint.

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

get_last_activities async

get_last_activities(codingamer_id=None, limit=4)

Get a codingamer's most recent activity feed entries.

Parameters:

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

    The codingamer whose recent activity to list. If not provided, defaults to the logged-in codingamer's ID.

  • limit (int, default: 4 ) –

    Maximum number of activity entries to return. Defaults to 4 (the only value observed in practice, believed to be the max entry count).

Returns:

  • list[CgLastActivity]

    A list of CgLastActivity 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/last_activities.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 get_last_activities(
            self,
            codingamer_id: int | None = None,
            limit: int = 4,
        ) -> list[CgLastActivity]:
    """Get a codingamer's most recent activity feed entries.

    Args:
        codingamer_id: The codingamer whose recent activity to list. If not provided,
                       defaults to the logged-in codingamer's ID.
        limit:         Maximum number of activity entries to return. Defaults to 4 (the only
                       value observed in practice, believed to be the max entry count).

    Returns:
        A list of CgLastActivity 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.
    """
    if codingamer_id is None:
        await self.require_authenticate()
        codingamer_id = self.client.codingamer_id
        if codingamer_id is None:
            raise CgAuthenticationError()
    raw_activities = await self.service_request_to_list(
            "getLastActivities", [codingamer_id, limit])
    return CgLastActivity.from_list(cast(list[JsonDict], raw_activities))