diff --git a/core/clients/aggregators/nordigen.py b/core/clients/aggregators/nordigen.py index f70b781..46eedfc 100644 --- a/core/clients/aggregators/nordigen.py +++ b/core/clients/aggregators/nordigen.py @@ -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 diff --git a/core/lib/schemas/nordigen_s.py b/core/lib/schemas/nordigen_s.py index a6914e4..bda1d5a 100644 --- a/core/lib/schemas/nordigen_s.py +++ b/core/lib/schemas/nordigen_s.py @@ -195,15 +195,19 @@ class TransactionsNested(MyModel): class TransactionsBookedPending(MyModel): - booked: list[TransactionsNested] - pending: list[TransactionsNested] + booked: list[TransactionsNested] | None + pending: list[TransactionsNested] | None class Transactions(MyModel): - transactions: TransactionsBookedPending + transactions: TransactionsBookedPending | None + detail: str | None + status_code: int | None + summary: str | None TransactionsSchema = { - "booked": "transactions.booked", - "pending": "transactions.pending", + "transactions": "transactions", + "status_code": "status_code", + "summary": "summary", }