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: except ValidationError as err:
self.log.error(f"Validation error: {err}") self.log.error(f"Validation error: {err}")
return 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": if "bban" in parsed and parsed["currency"] == "GBP":
sort_code = parsed["bban"][0:6] sort_code = parsed["bban"][0:6]
account_number = parsed["bban"][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"] recipient = parsed["ownerName"]
del parsed["bban"] del parsed["bban"]
del parsed["iban"] del parsed["iban"]
@ -325,6 +331,7 @@ class Nordigen(util.Base):
def normalise_transactions(self, transactions): def normalise_transactions(self, transactions):
for transaction in transactions: for transaction in transactions:
# Rename ID # Rename ID
if "transactionId" in transaction:
transaction["transaction_id"] = transaction["transactionId"] transaction["transaction_id"] = transaction["transactionId"]
del transaction["transactionId"] del transaction["transactionId"]