Added default currency_code and currency_rate

This commit is contained in:
2022-05-27 21:54:08 +12:00
parent 409ea90a4b
commit 7eaf7c99dd

View File

@@ -18,7 +18,9 @@ class Client(object):
url, url,
username, username,
password, password,
company_id): company_id,
currency_code="NZD",
currency_rate="1.0"):
""" """
Create a new instance. Create a new instance.
Args: Args:
@@ -33,6 +35,8 @@ class Client(object):
} }
self.company_id = company_id self.company_id = company_id
self.default_params = {'company_id': company_id} self.default_params = {'company_id': company_id}
self.currency_code = currency_code
self.currency_rate = currency_rate
def call(self, method="get", endpoint=None, def call(self, method="get", endpoint=None,
**params) -> dict(): **params) -> dict():
@@ -69,7 +73,7 @@ class Client(object):
return data return data
def get_accounts(self, **params): def get_accounts(self, **params):
data = self.call(endpoint="accounts") data = self.call(endpoint="accounts", **params)
return data['data'] return data['data']
@@ -83,11 +87,17 @@ class Client(object):
reference=None, # Reference for the payment reference=None, # Reference for the payment
payment_method=None, # Payment method payment_method=None, # Payment method
currency_code=None, # Currency code currency_code=None, # Currency code
currency_rate=None, # Currency rate currency_rate=None,# Currency rate
amount=None, # Amount received/paid amount=None, # Amount received/paid
**params # Any additional parameters **params # Any additional parameters
): ):
if currency_code is None:
# Set default value from class
currency_code = self.currency_code
if currency_rate is None:
# Set default value from class
currency_rate = self.currency_rate
data = self.call(endpoint="transactions", data = self.call(endpoint="transactions",
method="POST", method="POST",