Added create transfer

This commit is contained in:
2022-05-30 15:21:14 +12:00
parent 96d4523ef4
commit c92fb0d1ee
4 changed files with 60 additions and 3 deletions

View File

@@ -116,8 +116,29 @@ class Client(object):
reference=reference,
currency_code=currency_code,
currency_rate=currency_rate,
amount=amount,
amount=EnsurePositiveInteger(amount),
description=description,
**params
)
return data
def create_transfer(self,
from_account_id=None, # Account ID to create transfer from
to_account_id=None, # Account ID to create transfer to
transferred_at=None, # Date of expense/transfer or income
payment_method="Bank Transfer", # Payment method
amount=None, # Amount received/paid
**params # Any additional parameters
):
data = self.call(endpoint="transfers",
method="POST",
from_account_id=from_account_id,
to_account_id=to_account_id,
transferred_at=transferred_at,
payment_method=payment_method,
amount=EnsurePositiveInteger(amount),
**params
)
return data

View File

@@ -6,4 +6,7 @@ def MergeDict(dict1, dict2):
def RemoveFromString(items, string):
for item in items:
string = string.replace(item, '')
return string
return string
def EnsurePositiveInteger(number):
return float(number) if float(number) > 0 else (float(number) * -1)