Client

Clients are used to make http requests to API server

Abstract client

Base class for all clients

class chsu_schedule_api.client.abc.ABCHttpClient(*args, **kwargs)[source]

Abstract http client class.

If you want to implement your own client, you should inherit this class.

abstract async close() None[source]

Close http session.

abstract async request(method: str, url: str, data: object = None, **kwargs) str | None[source]

Make a raw http request.

abstract async request_json(method: str, url: str, data: object = None, **kwargs) dict | list | str | int[source]

Make a json http request.

Aiohttp client

Client implementation based on aiohttp.ClientSession
Aiohttp client is used by default in chsu_schedule_api.api.CHSUApi
class chsu_schedule_api.client.aiohttp.AiohttpClient(session: ClientSession | None = None)[source]

Http-client based on aiohttp.

async close() None[source]

Close aiohttp session.

async request(method: str, url: str, data: object = None, **kwargs) str | None[source]

Make an aiohttp request.

Parameters:
  • method – method for the request

  • url – request url

  • data – query string, defaults to None

Returns:

response raw data

async request_json(method: str, url: str, data: object = None, **kwargs) dict | list | str | int[source]

Make an aiohttp json request.

Parameters:
  • method – method for the request

  • url – request url

  • data – query string, defaults to None

Raises:
Returns:

response json data