More relaxed field handling

This commit is contained in:
Mark Veidemanis 2022-04-24 19:21:45 +01:00
parent ce234e69f6
commit f78c351e75
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 10 additions and 3 deletions

View File

@ -243,10 +243,16 @@ class Nordigen(util.Base):
except ValidationError as err:
self.log.error(f"Validation error: {err}")
return
parsed = obj.to_dict()["account"]
parsed_obj = obj.to_dict()
if "account" not in parsed_obj:
return False
parsed = parsed_obj["account"]
if "bban" in parsed and parsed["currency"] == "GBP":
sort_code = parsed["bban"][0:6]
account_number = parsed["bban"][6:]
if "ownerName" not in parsed:
self.log.warning(f"No owner name in parsed, cannot use: {account_id}")
return False
recipient = parsed["ownerName"]
del parsed["bban"]
del parsed["iban"]
@ -325,8 +331,9 @@ class Nordigen(util.Base):
def normalise_transactions(self, transactions):
for transaction in transactions:
# Rename ID
transaction["transaction_id"] = transaction["transactionId"]
del transaction["transactionId"]
if "transactionId" in transaction:
transaction["transaction_id"] = transaction["transactionId"]
del transaction["transactionId"]
# Rename timestamp
transaction["timestamp"] = transaction["bookingDate"]