Libraries refactor and add some sinks #4

Closed
m wants to merge 136 commits from library-refactor into master
1 changed files with 5 additions and 3 deletions
Showing only changes of commit c3406bd9ea - Show all commits

View File

@ -1,5 +1,6 @@
# Twisted/Klein imports # Twisted/Klein imports
from twisted.logger import Logger from twisted.logger import Logger
from twisted.internet.task import LoopingCall
# Other library imports # Other library imports
import requests import requests
@ -19,6 +20,8 @@ class TrueLayer(object):
def __init__(self): def __init__(self):
self.log = Logger("truelayer") self.log = Logger("truelayer")
self.token = None self.token = None
self.lc = LoopingCall(self.get_new_token)
self.lc.start(int(settings.TrueLayer.RefreshSec))
def setup_auth(self): def setup_auth(self):
pass pass
@ -101,13 +104,12 @@ class TrueLayer(object):
Get a list of accounts. Get a list of accounts.
""" """
headers = {"Authorization": f"Bearer {self.token}"} headers = {"Authorization": f"Bearer {self.token}"}
# path = f"{settings.TrueLayer.DataBase}/accounts" path = f"{settings.TrueLayer.DataBase}/accounts"
path = "https://api.truelayer-sandbox.com/data/v1/accounts"
r = requests.get(path, headers=headers) r = requests.get(path, headers=headers)
try: try:
parsed = r.json() parsed = r.json()
except JSONDecodeError: except JSONDecodeError:
self.log.error("Error parsing institutions response: {content}", content=r.content) self.log.error("Error parsing institutions response: {content}", content=r.content)
return False return False
print("GET ACCOUNTS", parsed)
return parsed return parsed