added some qol connection items
This commit is contained in:
parent
9eb116502a
commit
8fb43fdf6e
@ -43,7 +43,8 @@ class Connection(AbstractConnectionClient):
|
||||
secret=self.PLAID_SECRET,
|
||||
environment=self.PLAID_ENV,
|
||||
api_version='2019-05-29',
|
||||
webhook='https://qrtr-services.herokuapp.com/connection/plaid-webhook/')
|
||||
#webhook='https://qrtr-services.herokuapp.com/connection/plaid-webhook/'
|
||||
)
|
||||
public_key = self.credentials.get('public_token')
|
||||
auth_token = self.credentials.get('auth_token')
|
||||
if not auth_token and public_key:
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
from django.db import models
|
||||
import jsonfield
|
||||
from qrtr_account.models import Account
|
||||
import importlib
|
||||
|
||||
|
||||
class ConnectionType(models.Model):
|
||||
@ -20,5 +21,11 @@ class Connection(models.Model):
|
||||
credentials = jsonfield.JSONField()
|
||||
account = models.ForeignKey(Account, on_delete=models.CASCADE)
|
||||
|
||||
def connect(self):
|
||||
conn_lib = importlib.import_module("connection.connections."
|
||||
f"{self.type.filename}")
|
||||
conn = conn_lib.Connection(self.credentials)
|
||||
return conn
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name}"
|
||||
return f"{self.name}"
|
||||
4
connection/tasks.py
Normal file
4
connection/tasks.py
Normal file
@ -0,0 +1,4 @@
|
||||
from qrtr_account.models import Transaction
|
||||
from connection.models import Connection
|
||||
|
||||
|
||||
@ -70,8 +70,9 @@ class ConnectionViewSet(viewsets.ModelViewSet):
|
||||
except ValueError:
|
||||
return Response(status=status.HTTP_503,
|
||||
data="ERROR: Invalid public_token")
|
||||
except Exception:
|
||||
return Response(status=status.HTTP_500,
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
data="ERROR: Unable to contact Plaid")
|
||||
with transaction.atomic():
|
||||
conn, created = Connection.objects \
|
||||
|
||||
Loading…
Reference in New Issue
Block a user