diff --git a/akauntingpy/api.py b/akauntingpy/api.py index 3848a88..0922bce 100644 --- a/akauntingpy/api.py +++ b/akauntingpy/api.py @@ -1,12 +1,15 @@ import requests +import logging from requests.auth import HTTPBasicAuth from akauntingpy import exceptions from akauntingpy.helpers import * -__version__ = "1.0.3" +__version__ = "1.0.5" +logger = logging.getLogger(__name__) + class Client(object): """ Akaunting interface. @@ -68,6 +71,9 @@ class Client(object): "\n".join(errors)) # elif response.status_code != 200 and response.status_code != 201: # raise exceptions.Error(response_['message']) + elif response.status_code == 429: + # We hit the maximum requests + raise exceptions.TooManyAttempts(response_['message']) return response_ def ping(self): @@ -162,9 +168,15 @@ class Client(object): transferred_at=None, # Date of expense/transfer or income payment_method="Bank Transfer", # Payment method amount=None, # Amount received/paid - **params # Any additional parameters + **params # Any additional parameters ): - + logger.info("Transfer called with parameters") + logger.info("from_account_id: %s", from_account_id) + logger.info("to_account_id: %s", to_account_id) + logger.info("transferred_at: %s", transferred_at) + logger.info("payment_method: %s", payment_method) + logger.info("amount: %s", amount) + data = self.call(endpoint="transfers", method="POST", from_account_id=from_account_id, diff --git a/akauntingpy/exceptions.py b/akauntingpy/exceptions.py index ec738b1..4b9def7 100644 --- a/akauntingpy/exceptions.py +++ b/akauntingpy/exceptions.py @@ -31,6 +31,14 @@ class ContactNotFound(Error): """ Account not found + Args: + Error (_type_): _description_ + """ + +class TooManyAttempts(Error): + """ + Too Many attempts to API + Args: Error (_type_): _description_ """ \ No newline at end of file