Handle errors in fetching transactions
This commit is contained in:
parent
7e7b145b04
commit
8ad0f0573f
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue