|
| 1 | + |
1 | 2 | # 1. First, query Ldot to find new people who need to be added to Qualtrics. This will be done by looking for people who have been added to Ldot in the last 24 hours and checking if they are already in Qualtrics. |
2 | 3 | # 2. For each new person, add them to the appropriate mailing list in Qualtrics. This will involve using the Qualtrics API to add the person's information to the mailing list. |
3 | 4 | # 3. After adding the person to the mailing list, send them an email invitation to |
4 | 5 |
|
| 6 | +# Grab the client ID and secret from the config file new_ldot_workflows\ldot_config.json |
5 | 7 |
|
6 | 8 |
|
7 | | -# I think it would be nice to make this a little app on openshift |
8 | | -# So let's make everything into sepaate functions and then connect them to buttons in the UI. We can use Flask for the backend and React for the frontend.. |
9 | | -# And yes save the reuslts in the meantime |
10 | 9 |
|
| 10 | +import json |
11 | 11 | import requests |
12 | 12 |
|
13 | | -# I think I ned to get the list of people and their IDs where they are at the state of point where they're ready to be sent a survey invitation |
| 13 | +with open("new_ldot_workflows/ldot_config.json") as f: |
| 14 | + config = json.load(f) |
| 15 | +CLIENT_ID = config["client_id"] |
| 16 | +CLIENT_SECRET = config["client_secret"] |
| 17 | +LDOT_API_URL = config["LDOT_API_URL"] |
14 | 18 |
|
15 | 19 |
|
16 | | -LDOT_API_URL = "https://accware.memic.maastrichtuniversity.nl/memic_ldot_api/api/v1.1/" |
17 | | -STUDY_GUID = "5c9c6a47-c8d7-8142-a8c8-ccdcb8a8044b" |
| 20 | +response = requests.post( |
| 21 | + "https://accware.memic.maastrichtuniversity.nl/ldot_identity_server/connect/token", |
| 22 | + data={ |
| 23 | + "grant_type": "client_credentials", |
| 24 | + "client_id": CLIENT_ID, |
| 25 | + "client_secret": CLIENT_SECRET |
| 26 | + } |
| 27 | +) |
18 | 28 |
|
19 | | -study_events_url = f"{LDOT_API_URL}{STUDY_GUID}/Action" |
| 29 | +token = response.json()["access_token"] |
| 30 | +print(token) |
20 | 31 |
|
21 | | -headers={"accept": "application/json" |
| 32 | +headers={"accept": "application/json", |
| 33 | + "Authorization": f"Bearer {token}" |
22 | 34 | } |
23 | 35 |
|
24 | 36 | response = requests.get( |
25 | | - study_events_url, |
26 | | - auth=(), |
| 37 | + "https://accware.memic.maastrichtuniversity.nl/memic_ldot_api/api/v1.1/5c9c6a47-c8d7-8142-a8c8-ccdcb8a8044b/Action", |
27 | 38 | headers=headers |
28 | 39 | ) |
29 | 40 |
|
|
0 commit comments