Handle errors in fetching transactions

This commit is contained in:
2023-04-20 08:42:39 +01:00
parent 7e7b145b04
commit 8ad0f0573f
2 changed files with 17 additions and 7 deletions

View File

@@ -305,6 +305,12 @@ class NordigenClient(BaseClient, AggregatorClient):
path = f"accounts/{account_id}/transactions"
response = await self.call(path, schema="Transactions")
if response["status_code"] == 401:
log.error(
f"Error getting transactions for {account_id}: {response['summary']}"
)
return []
source = "booked"
# If requisition is specified, try to get the object
@@ -315,7 +321,7 @@ class NordigenClient(BaseClient, AggregatorClient):
if requisition:
source = requisition.transaction_source
parsed = response[source]
parsed = response["transactions"][source]
self.normalise_transactions(parsed, state=source)
if process:
@@ -323,7 +329,7 @@ class NordigenClient(BaseClient, AggregatorClient):
if pending:
if process:
raise Exception("Cannot process and get pending")
parsed_pending = response["pending"]
parsed_pending = response["transactions"]["pending"]
self.normalise_transactions(parsed_pending, state="pending")
parsed_pending.extend(parsed)
parsed = parsed_pending