2022-03-04 22:47:06 +00:00
|
|
|
# Other library imports
|
|
|
|
# import requests
|
|
|
|
# from json import dumps
|
|
|
|
|
|
|
|
# Project imports
|
|
|
|
# from settings import settings
|
|
|
|
import sinks.fidor
|
|
|
|
import sinks.nordigen
|
|
|
|
import sinks.truelayer
|
2022-03-05 21:52:31 +00:00
|
|
|
import util
|
2022-03-07 20:10:59 +00:00
|
|
|
from db import r
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
|
2022-03-05 21:52:31 +00:00
|
|
|
class Sinks(util.Base):
|
2022-03-04 22:47:06 +00:00
|
|
|
"""
|
|
|
|
Class to manage calls to various sinks.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self):
|
2022-03-05 21:52:31 +00:00
|
|
|
super().__init__()
|
2022-03-04 22:47:06 +00:00
|
|
|
self.fidor = sinks.fidor.Fidor()
|
|
|
|
self.nordigen = sinks.nordigen.Nordigen()
|
2022-03-07 19:59:30 +00:00
|
|
|
self.truelayer = sinks.truelayer.TrueLayer(self)
|
|
|
|
# setattr(self.truelayer, "sinks", self)
|
|
|
|
|
|
|
|
def got_transactions(self, bank, account_id, transactions):
|
|
|
|
print("GOT transactions", bank, account_id, transactions)
|
2022-03-07 20:10:59 +00:00
|
|
|
transaction_ids = [x["transaction_id"] for x in transactions]
|
|
|
|
print("IDS", transaction_ids)
|
|
|
|
new_key_name = f"new.transactions.{bank}.{account_id}"
|
|
|
|
old_key_name = f"transactions.{bank}.{account_id}"
|
|
|
|
r.sset(new_key_name, transaction_ids)
|
|
|
|
|
|
|
|
difference = r.sdiff(new_key_name, old_key_name)
|
|
|
|
print("difference", difference)
|
|
|
|
|
|
|
|
# Rename the new key to the old key so we can run the diff again
|
|
|
|
r.rename(new_key_name, old_key_name)
|
|
|
|
|
|
|
|
# self.transactions.transaction(transactions)
|