Skip to content

Commit

Permalink
feat (auto redirect): Remove Pool Id (#80)
Browse files Browse the repository at this point in the history
* Pulling Directory Id from secrets

* CR comments

* Update settings.py

---------

Co-authored-by: dzaslavskiy <dzaslavskiy@users.noreply.github.com>
  • Loading branch information
nathan-moore-97 and dzaslavskiy authored Jan 11, 2024
1 parent 7d7ad87 commit fdc797b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions qualtrix/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import fastapi
from fastapi import HTTPException
from pydantic import BaseModel, typing
from pydantic import BaseModel

from qualtrix import client, error
from qualtrix import client, error, settings

log = logging.getLogger(__name__)

Expand All @@ -28,7 +28,6 @@ class SessionModel(SurveyModel):


class RedirectModel(SurveyModel):
directoryId: str
targetSurveyId: str
responseId: str

Expand All @@ -50,8 +49,8 @@ async def get_response(request: ResponseModel):
async def get_redirect(request: RedirectModel):
try:
email = client.get_email(request.surveyId, request.responseId)
contact = client.get_contact(request.directoryId, email)
distribution = client.get_distribution(request.directoryId, contact["id"])
contact = client.get_contact(settings.DIRECTORY_ID, email)
distribution = client.get_distribution(settings.DIRECTORY_ID, contact["id"])
return client.get_link(request.targetSurveyId, distribution["distributionId"])
except error.QualtricsError as e:
logging.error(e)
Expand Down
6 changes: 3 additions & 3 deletions qualtrix/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
BASE_URL = config["base_url"]
DIRECTORY_ID = config["directory_id"]
else:
API_TOKEN = os.getenv("QX_API_TOKEN")
BASE_URL = os.getenv("QX_BASE_URL")
DIRECTORY_ID = os.getenv("QX_DIRECTORY_ID")
API_TOKEN = os.getenv("QUALTRIX_API_TOKEN")
BASE_URL = os.getenv("QUALTRIX_BASE_URL")
DIRECTORY_ID = os.getenv("QUALTRIX_DIRECTORY_ID")


except (json.JSONDecodeError, KeyError, FileNotFoundError) as err:
Expand Down

0 comments on commit fdc797b

Please sign in to comment.