1-
21import requests
3- from .qualtrics_settings import BASE_URL , HEADERS , QualtricsAPIError
2+ import json
3+
4+ with open ("new_ldot_workflows/qualtrics_config.json" ) as f :
5+ config = json .load (f )
6+ CLIENT_ID = config ["client_id" ]
7+ CLIENT_SECRET = config ["client_secret" ]
8+ QUALTRICS_BASE_URL = config ["QUALTRICS_BASE_URL" ]
9+
410
511
612def check_contact_in_mailing_list (participant_study_id : str , mailing_list_id : str , directory_id : str ) -> bool :
713 """Find who is already in that mailing list, check if the participant's ID is already there."""
814
915 print ("Checking for contact in mailing list... " )
10- endpoint = f"{ BASE_URL } /directories/{ directory_id } /mailinglists/{ mailing_list_id } /contacts"
16+ endpoint = f"{ QUALTRICS_BASE_URL } /directories/{ directory_id } /mailinglists/{ mailing_list_id } /contacts"
1117 try :
1218 response = requests .get (endpoint , headers = HEADERS )
1319 response .raise_for_status ()
@@ -30,7 +36,7 @@ def check_contact_in_mailing_list(participant_study_id: str, mailing_list_id: st
3036def add_contact_to_mailing_list (participant_study_id : str , embedded_data_field : str , mailing_list_id : str , directory_id : str ) -> None :
3137 """Add contact to a mailing list"""
3238
33- endpoint = f"{ BASE_URL } /directories/{ directory_id } /mailinglists/{ mailing_list_id } /contacts"
39+ endpoint = f"{ QUALTRICS_BASE_URL } /directories/{ directory_id } /mailinglists/{ mailing_list_id } /contacts"
3440 contact_information_payload = {
3541 "extRef" : participant_study_id ,
3642 "embeddedData" : {
@@ -55,7 +61,7 @@ def get_personal_link(qualtrics_survey_id: str, distribution_id: str, participan
5561 https://survey.uu.nl/jfe/form/SV_efCMOg6wHU0T8ii?Q_CHLqe2Pdrma&_g_=g
5662 """
5763 print (f"Fetching personal link for { participant_study_id } ... " )
58- endpoint = f"{ BASE_URL } /distributions/{ distribution_id } /links"
64+ endpoint = f"{ QUALTRICS_BASE_URL } /distributions/{ distribution_id } /links"
5965 parameters = {
6066 "surveyId" : str (qualtrics_survey_id )
6167 }
@@ -105,5 +111,5 @@ def add_individuals_to_survey(participant_ids_list: list, embedded_data_field, d
105111
106112 print (link )
107113
108-
114+
109115 # print(get_mailing_list_id_of_distribution("SV_efCMOg6wHU0T8ii", "EMD_SZFeoK7LAJBHU4d"))
0 commit comments