diff --git a/qualtrix/api.py b/qualtrix/api.py index 9cd688d..0a30273 100644 --- a/qualtrix/api.py +++ b/qualtrix/api.py @@ -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__) @@ -28,7 +28,6 @@ class SessionModel(SurveyModel): class RedirectModel(SurveyModel): - directoryId: str targetSurveyId: str responseId: str @@ -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) diff --git a/qualtrix/settings.py b/qualtrix/settings.py index e3a124c..a226869 100644 --- a/qualtrix/settings.py +++ b/qualtrix/settings.py @@ -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: