From f78c351e75649d2e31ab22e0fe345cf3351b5eaa Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sun, 24 Apr 2022 19:21:45 +0100 Subject: [PATCH] More relaxed field handling --- handler/sinks/nordigen.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/handler/sinks/nordigen.py b/handler/sinks/nordigen.py index 38c14f2..37a9f21 100644 --- a/handler/sinks/nordigen.py +++ b/handler/sinks/nordigen.py @@ -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"]