codingame_tools.client.service.cg_service¶
cg_service
¶
Service endpoints for the async CodinGame client.
CgService
¶
CgService(client, service_name)
Base class for a service endpoint.
Source code in codingame_tools/client/service/cg_service.py
24 25 26 | |
service_request
async
¶
service_request(func_name, args=None, *, require_login=True)
Make a service request to the CodinGame API.
Parameters:
-
func_name(str) –The name of the service function to call.
-
args(list[JsonData] | None, default:None) –The arguments to pass to the service function. Defaults to an empty list.
-
require_login(bool, default:True) –Whether the request requires a valid login. Defaults to True.
Returns:
-
JsonData–The decoded JSON response from the service function.
Source code in codingame_tools/client/service/cg_service.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
service_request_to_dict
async
¶
service_request_to_dict(func_name, args=None, *, require_login=True)
Make a service request to the CodinGame API and return the response as a dict.
Parameters:
-
func_name(str) –The name of the service function to call.
-
args(list[JsonData] | None, default:None) –The arguments to pass to the service function. Defaults to an empty list.
-
require_login(bool, default:True) –Whether the request requires a valid login. Defaults to True.
Returns:
-
dict[str, JsonData]–The decoded JSON response from the service function as a dict.
Source code in codingame_tools/client/service/cg_service.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
service_request_to_list
async
¶
service_request_to_list(func_name, args=None, *, require_login=True)
Make a service request to the CodinGame API and return the response as a list.
Parameters:
-
func_name(str) –The name of the service function to call.
-
args(list[JsonData] | None, default:None) –The arguments to pass to the service function. Defaults to an empty list.
-
require_login(bool, default:True) –Whether the request requires a valid login. Defaults to True.
Returns:
-
list[JsonData]–The decoded JSON response from the service function as a list.
Source code in codingame_tools/client/service/cg_service.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
require_authenticate
async
¶
require_authenticate()
Ensure that the client is authenticated, logging in if necessary.
Source code in codingame_tools/client/service/cg_service.py
91 92 93 | |
CgServiceHelper
¶
CgServiceHelper(service)
Bases: Generic[TService]
Base class for a service endpoint's helper object.
Helper objects provide higher-level convenience methods for a service--e.g. retry/polling logic or normalized wrappers built on top of one or more of the service's own calls--without needing a whole parallel module hierarchy alongside the service classes. Helper methods must never do anything a caller could not already do with the service's own public methods; there is no special access or hidden behavior here, just more convenient combinations of already- public building blocks.
Every service exposes a .helper attribute of its own dedicated helper subclass, even one
that (like this base class) currently has no extra methods--so the attribute's presence and
static type never change later just because functionality is added to it.
Generic over TService (bound to CgService) so that each service's helper subclass
need only parameterize this base class with its own service type--e.g.
class CgContributionServiceHelper(CgServiceHelper["CgContributionService"])--
to get a correctly, statically narrowed self.service with no __init__ override and no
unchecked attribute redeclaration. Any methods added here on the base class are themselves
generic over TService and thus usable from every helper subclass unchanged.
Source code in codingame_tools/client/service/cg_service.py
124 125 | |