Private functions#

HTTPAPIWrapper._checked_get_or_post#

Runs a GET or POST request returning the result as a JSON with optional logging and error raising.

Signature:

  • **HTTPAPIWrapper._checked_get_or_post**(self, url, the_request, is_post, requests_kwargs, good_message, bad_message, raise_errors)

Parameters:

  • __url:__ The https://… url.

  • __the_request:__ The “json” kwarg is set to this. Can be None in which no “json” will be set.

  • __is_post:__ True for post, False for get.

  • __requests_kwargs=None:__ Dict of extra arguments to send to requests/aiohttp. None is equivalent to {}.

  • __good_message=None:__ The string-valued message to logger.debug. None means do not log.

  • __bad_message=’This HTTPs request failed’:__ The string-valued message to prepend to logger.error if the response isnt code 10000.

  • __raise_errors=True:__ Raise a BadResponseException if the request returns an error.

Returns:

  • The https response as a dict, using requests/aiohttp.post(…).json() to parse it.

Raises:

  • BadResponseException if raise_errors=True and the response is an error response.

HTTPAPIWrapper._xtract_character#

Signature:

  • **HTTPAPIWrapper._xtract_character**(self, resp_data)

Parameters:

  • __resp_data:__ JSON response data.

Returns:

  • The Character object.

Raises:

  • (this function does not raise any notable errors)

HTTPAPIWrapper._upload_extension#

Gets the upload URL and needed fields for uploading a file.

Signature:

  • **HTTPAPIWrapper._upload_extension**(self, extension)

Parameters:

  • __extension:__ String-valued extension.

Returns:

  • (upload_url or None, upload_fields).

Raises:

  • (this function does not raise any notable errors)

HTTPAPIWrapper._do_upload#

Uploads a file to the given upload URL with the given upload fields.

Signature:

  • **HTTPAPIWrapper._do_upload**(self, upload_url, upload_fields, file_path)

Parameters:

  • __upload_url:__ Obtained with _upload_extension.

  • __upload_fields:__ Obtained with _upload_extension.

  • __file_path:__ The path of the file.

Returns:

  • The full URL string of the uploaded file. None if doesn’t receive a valid response (error condition).

Raises:

  • Exception: If the file upload fails, this function will raise an exception detailing the error.

HTTPAPIWrapper.__str__#

The string output function for debugging.

Signature:

  • **HTTPAPIWrapper.__str__**(self)

Parameters:

  • __(this class constructor accepts no arguments):__

Returns:

  • The easy-to-read string summary.

Raises:

  • (this function does not raise any notable errors)

HTTPAPIWrapper.__repr__#

The string output function for debugging.

Signature:

  • **HTTPAPIWrapper.__repr__**(self)

Parameters:

  • __(this class constructor accepts no arguments):__

Returns:

  • The easy-to-read string summary.

Raises:

  • (this function does not raise any notable errors)

Private attributes#

_URL2example_response

HTTPAPIWrapper._checked_get_or_post._URL2example_response

HTTPAPIWrapper._do_upload._

HTTPAPIWrapper._checked_get_or_post._URL2example_response