Skip to content

codingame_tools.client.service.services.user

user

Async User service endpoint.

CgUserServiceHelper

CgUserServiceHelper(service)

Bases: CgServiceHelper['CgUserService']

Helper methods for CgUserService. Currently empty.

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

CgUserService

CgUserService(client)

Bases: CgService

Async User service endpoint.

Source code in codingame_tools/client/service/services/user.py
24
25
26
def __init__(self, client: CgClient) -> None:
    super().__init__(client, "User")
    self.helper = CgUserServiceHelper(self)

update_user_properties async

update_user_properties(properties, codingamer_id=None)

Update a subset of a codingamer's account properties.

Only fields explicitly set on properties (i.e. not left as None) are sent to the server and updated--all other properties are left unchanged. The server returns an empty string on success, which is discarded.

Only one property (contributions_list_last_visit) is known and modeled on CgUserProperties so far; this will need to grow incrementally as more properties are discovered.

Parameters:

  • properties (CgUserProperties) –

    The properties to update; unset (None) fields are left unchanged.

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

    The codingamer to update. If not provided, defaults to the logged-in codingamer's ID.

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, or if the status code is not 2xx.

Source code in codingame_tools/client/service/services/user.py
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
async def update_user_properties(
            self,
            properties: CgUserProperties,
            codingamer_id: int | None = None,
        ) -> None:
    """Update a subset of a codingamer's account properties.

       Only fields explicitly set on `properties` (i.e. not left as None) are sent to the
       server and updated--all other properties are left unchanged. The server returns an
       empty string on success, which is discarded.

       Only one property (`contributions_list_last_visit`) is known and modeled on
       `CgUserProperties` so far; this will need to grow incrementally as more properties
       are discovered.

    Args:
        properties:    The properties to update; unset (None) fields are left unchanged.
        codingamer_id: The codingamer to update. If not provided, defaults to the logged-in
                       codingamer's ID.

    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, or if the status code is not 2xx.
    """
    if codingamer_id is None:
        await self.require_authenticate()
        codingamer_id = self.client.codingamer_id
        if codingamer_id is None:
            raise CgAuthenticationError()
    await self.service_request("updateUserProperties", [codingamer_id, properties.to_dict()])