|
|
|
@ -45,6 +45,14 @@ class Nordigen(util.Base):
|
|
|
|
|
|
|
|
|
|
self.sinks.got_account_info("nordigen", account_infos)
|
|
|
|
|
|
|
|
|
|
self.lc_tx = LoopingCall(self.transaction_loop)
|
|
|
|
|
self.lc_tx.start(int(settings.Nordigen.RefreshSec))
|
|
|
|
|
|
|
|
|
|
def transaction_loop(self):
|
|
|
|
|
for account_id in self.banks:
|
|
|
|
|
transactions = self.get_transactions(account_id)
|
|
|
|
|
self.sinks.got_transactions("nordigen", account_id, transactions)
|
|
|
|
|
|
|
|
|
|
def get_access_token(self):
|
|
|
|
|
"""
|
|
|
|
|
Get an access token.
|
|
|
|
@ -246,6 +254,23 @@ class Nordigen(util.Base):
|
|
|
|
|
to_return[req["institution_id"]] = [account_info]
|
|
|
|
|
return to_return
|
|
|
|
|
|
|
|
|
|
def normalise_transactions(self, transactions):
|
|
|
|
|
for transaction in transactions:
|
|
|
|
|
# Rename ID
|
|
|
|
|
transaction["transaction_id"] = transaction["transactionId"]
|
|
|
|
|
del transaction["transactionId"]
|
|
|
|
|
|
|
|
|
|
# Rename timestamp
|
|
|
|
|
transaction["timestamp"] = transaction["bookingDate"]
|
|
|
|
|
del transaction["bookingDate"]
|
|
|
|
|
|
|
|
|
|
transaction["amount"] = float(transaction["transactionAmount"]["amount"])
|
|
|
|
|
transaction["currency"] = transaction["transactionAmount"]["currency"]
|
|
|
|
|
del transaction["transactionAmount"]
|
|
|
|
|
|
|
|
|
|
transaction["reference"] = transaction["remittanceInformationUnstructured"]
|
|
|
|
|
del transaction["remittanceInformationUnstructured"]
|
|
|
|
|
|
|
|
|
|
def get_transactions(self, account_id):
|
|
|
|
|
"""
|
|
|
|
|
Get all transactions for an account.
|
|
|
|
@ -257,4 +282,6 @@ class Nordigen(util.Base):
|
|
|
|
|
path = f"{settings.Nordigen.Base}/accounts/{account_id}/transactions/"
|
|
|
|
|
r = requests.get(path, headers=headers)
|
|
|
|
|
obj = TXRoot.from_json(r.content)
|
|
|
|
|
return obj.to_dict()["transactions"]["booked"]
|
|
|
|
|
parsed = obj.to_dict()["transactions"]["booked"]
|
|
|
|
|
self.normalise_transactions(parsed)
|
|
|
|
|
return parsed
|
|
|
|
|