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"
|
path = f"accounts/{account_id}/transactions"
|
||||||
response = await self.call(path, schema="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"
|
source = "booked"
|
||||||
|
|
||||||
# If requisition is specified, try to get the object
|
# If requisition is specified, try to get the object
|
||||||
|
@ -315,7 +321,7 @@ class NordigenClient(BaseClient, AggregatorClient):
|
||||||
if requisition:
|
if requisition:
|
||||||
source = requisition.transaction_source
|
source = requisition.transaction_source
|
||||||
|
|
||||||
parsed = response[source]
|
parsed = response["transactions"][source]
|
||||||
self.normalise_transactions(parsed, state=source)
|
self.normalise_transactions(parsed, state=source)
|
||||||
|
|
||||||
if process:
|
if process:
|
||||||
|
@ -323,7 +329,7 @@ class NordigenClient(BaseClient, AggregatorClient):
|
||||||
if pending:
|
if pending:
|
||||||
if process:
|
if process:
|
||||||
raise Exception("Cannot process and get pending")
|
raise Exception("Cannot process and get pending")
|
||||||
parsed_pending = response["pending"]
|
parsed_pending = response["transactions"]["pending"]
|
||||||
self.normalise_transactions(parsed_pending, state="pending")
|
self.normalise_transactions(parsed_pending, state="pending")
|
||||||
parsed_pending.extend(parsed)
|
parsed_pending.extend(parsed)
|
||||||
parsed = parsed_pending
|
parsed = parsed_pending
|
||||||
|
|
|
@ -195,15 +195,19 @@ class TransactionsNested(MyModel):
|
||||||
|
|
||||||
|
|
||||||
class TransactionsBookedPending(MyModel):
|
class TransactionsBookedPending(MyModel):
|
||||||
booked: list[TransactionsNested]
|
booked: list[TransactionsNested] | None
|
||||||
pending: list[TransactionsNested]
|
pending: list[TransactionsNested] | None
|
||||||
|
|
||||||
|
|
||||||
class Transactions(MyModel):
|
class Transactions(MyModel):
|
||||||
transactions: TransactionsBookedPending
|
transactions: TransactionsBookedPending | None
|
||||||
|
detail: str | None
|
||||||
|
status_code: int | None
|
||||||
|
summary: str | None
|
||||||
|
|
||||||
|
|
||||||
TransactionsSchema = {
|
TransactionsSchema = {
|
||||||
"booked": "transactions.booked",
|
"transactions": "transactions",
|
||||||
"pending": "transactions.pending",
|
"status_code": "status_code",
|
||||||
|
"summary": "summary",
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue