unofficial_tabdeal_api.base

This module holds the BaseClass.

Classes

BaseClass

This is the base class, stores GET and POST functions.

Module Contents

class unofficial_tabdeal_api.base.BaseClass(*, user_hash, authorization_key, _is_test=False)

This is the base class, stores GET and POST functions.

Parameters:
  • user_hash (str)

  • authorization_key (str)

  • _is_test (bool)

_client_session: aiohttp.ClientSession
_logger: logging.Logger
async close()

Close the aiohttp client session.

Return type:

None

async __aenter__()

Enter the async context manager.

Return type:

Self

async __aexit__(exc_type, exc, tb)

Exit the async context manager and close the session.

Parameters:
Return type:

None

async _get_data_from_server(*, connection_url, queries=None)

Gets data from specified url and returns the parsed json back.

Parameters:
  • connection_url (str) – Url of the server to get data from

  • queries (dict[str, Any] | None, optional) – a Dictionary of queries. Defaults to None.

Returns:

a Dictionary or a list of dictionaries

Return type:

dict[str, Any] | list[dict[str, Any]]

async _post_data_to_server(*, connection_url, data)

Posts data to specified url and returns the result of request.

Parameters:
  • connection_url (str) – Url of server to post data to

  • data (str) – Stringed json data to send to server

Returns:

A Dictionary or a list of dictionaries.

Return type:

dict[str, Any] | list[dict[str, Any]]

async _check_response(response)

Check the server response and raise appropriate exception in case of an error.

Parameters:

response (ClientResponse) – Response from server

Raises:
  • AuthorizationError – Raised when the authorization key is invalid or expired

  • Error – Raised for all other errors

Return type:

None

_raise_specific_error(status_code, server_response)

Raise a specific exception based on the server response content.

Parameters:
  • status_code (int) – The status code of the response

  • server_response (str) – The content of the response

Raises:
  • exc_class – The specific exception class to raise

  • RequestError – Raised for all other errors

Return type:

None