API

class altapay.API(**kwargs)
download(resource, parameters={}, headers={})

Downloads a resource. Acts as a custom HTTP GET. Not that it is considered the callers responsibility to actually flush/close the stream.

get(resource, parameters={}, headers={})

Perform a GET HTTP request on a resource.

Parameters:
  • resource – the resource to GET
  • parameters – a dictionary of GET parameters for the resource
  • headers – optional headers. If specified, these will override the default headers.
Returns:

A response from the AltaPay service as a dict.

Raises:
UnauthorizedAccessError:
 If the supplied credentials are not valid.
ResponseStatusError:
 If the response code from AltaPay is not a subset of the allowed response codes.
login()

Validates the account name and password against the AltaPay service. This method should always be called before attempting any other calls, and is automatically called once the altapay.api.API object is instantiated, unless explictly disabled.

Raises:
UnauthorizedAccessError: if the supplied credentials are not valid.
post(resource, parameters={}, data={}, headers={})

Perform a POST HTTP requeste on a resource.

Parameters:
  • resource – the resource to POST to
  • parameters – a dictionary of GET parameters for the resource
  • data – a dictionary of POST parameters for the resource
  • headers – optional headers. If specified, these will override the default headers.
Returns:

A response from the AltaPay service as a dict.

Raises:
UnauthorizedAccessError:
 If the supplied credentials are not valid.
ResponseStatusError:
 If the response code from AltaPay is not a subset of the allowed response codes.
test_connection()

Tests the connection to the AltaPay service. This operation does not require valid API credentials, and as such can only be used to assert if AltaPay is responding.

Return type:True if a valid response is returned, otherwise False.