pluto/handler/lib/serde/nordigen.py

126 lines
2.9 KiB
Python

from serde import Model, fields
class Amount(Model):
amount: fields.Str()
currency: fields.Str()
class TransactionBBAN(Model):
bban: fields.Optional(fields.Str())
class ExchangeInstructedAmount(Model):
amount: fields.Str()
currency: fields.Str()
class TransactionCurrencyExchange(Model):
exchangeRate: fields.Str()
instructedAmount: fields.Nested(ExchangeInstructedAmount)
sourceCurrency: fields.Str()
targetCurrency: fields.Str()
unitCurrency: fields.Str()
class Transaction(Model):
bookingDate: fields.Date()
creditorAccount: fields.Optional(fields.Nested(TransactionBBAN))
creditorName: fields.Optional(fields.Str())
debtorName: fields.Optional(fields.Str())
currencyExchange: fields.Optional(fields.Nested(TransactionCurrencyExchange))
proprietaryBankTransactionCode: fields.Optional(fields.Str())
remittanceInformationUnstructured: fields.Optional(fields.Str())
transactionAmount: fields.Nested(Amount)
transactionId: fields.Optional(fields.Str())
class Pending(Transaction):
pass
class Booked(Transaction):
pass
class Transactions(Model):
pending: fields.List(Pending)
booked: fields.List(Booked)
class TXRoot(Model):
transactions: fields.Optional(fields.Nested(Transactions))
class AccessToken(Model):
access: fields.Str()
class Institution(Model):
id: fields.Str()
name: fields.Str()
bic: fields.Str()
transaction_total_days: fields.Str()
countries: fields.List()
logo: fields.Url()
class Institutions(Model):
institutions: fields.List(Institution)
class Agreement(Model):
id: fields.Str()
created: fields.DateTime()
redirect: fields.Url()
status: fields.Str()
institution_id: fields.Str()
agreement: fields.Str()
reference: fields.Str()
accounts: fields.List()
link: fields.Url()
ssn: fields.Literal(None) # ?
account_selection: fields.Bool()
redirect_immediate: fields.Bool()
class Requisitions(Model):
count: fields.Int()
next: fields.Literal(None) # wrong
previous: fields.Literal(None) # wrong
results: fields.List(Agreement)
class Account(Model):
resourceId: fields.Optional(fields.Str())
iban: fields.Optional(fields.Str())
bban: fields.Optional(fields.Str())
currency: fields.Str()
ownerName: fields.Optional(fields.Str())
status: fields.Optional(fields.Str())
details: fields.Optional(fields.Str())
class AccountDetails(Model):
account: fields.Optional(fields.Nested(Account))
class AccountBalanceAmount(Model):
amount: fields.Str()
currency: fields.Str()
class AccountBalances(Model):
balanceAmount: fields.Nested(AccountBalanceAmount)
balanceType: fields.Str()
referenceDate: fields.Date()
class AccountBalancesRoot(Model):
balances = fields.Optional(fields.List(AccountBalances))
class RequisitionResponse(Model):
summary: fields.Str()
detail: fields.Str()