Fixed plaid connection attaching to the wrong account
This commit is contained in:
parent
6f728d8792
commit
b5b9604e63
@ -33,6 +33,7 @@ class ConnectionViewSet(viewsets.ModelViewSet):
|
||||
public_token = request.data.get("public_token")
|
||||
name = request.data.get("name", "dummyName")
|
||||
account_id = request.data.get("account")
|
||||
print(f"Account ID Detected: {account_id}")
|
||||
if public_token is None:
|
||||
return Response(
|
||||
status=status.HTTP_400_BAD_REQUEST,
|
||||
@ -42,11 +43,13 @@ class ConnectionViewSet(viewsets.ModelViewSet):
|
||||
status=status.HTTP_400_BAD_REQUEST,
|
||||
data="ERROR: missing account_id")
|
||||
accounts = Account.objects.filter(pk=account_id)
|
||||
|
||||
if not accounts:
|
||||
return Response(
|
||||
status=status.HTTP_400_BAD_REQUEST,
|
||||
data="ERROR: invalid account_id")
|
||||
else:
|
||||
print(f"Account Found: {accounts[0]}")
|
||||
account = accounts[0]
|
||||
print(request)
|
||||
plaid = importlib.import_module(f"connection.connections.plaid_client")
|
||||
|
||||
@ -34,11 +34,16 @@ class UserViewSet(viewsets.ModelViewSet):
|
||||
request.user.admin_accounts.all() | \
|
||||
request.user.view_accounts.all()
|
||||
for qrtr_account in user_qrtr_accounts.distinct():
|
||||
print(f"Getting Connections for {qrtr_account}")
|
||||
connections = qrtr_account.connection_set.all()
|
||||
print(connections)
|
||||
for connection in connections:
|
||||
print("Getting items from plaid for given account")
|
||||
print(connection)
|
||||
conn_name = connection.type.name
|
||||
conn_accs = []
|
||||
client_lib = importlib.import_module(f"connection.connections.{connection.type.filename}")
|
||||
print(type(connection.credentials))
|
||||
client = client_lib.Connection(connection.credentials)
|
||||
connection.credentials = client.credentials
|
||||
connection.save()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user