-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathexample_usage.py
56 lines (46 loc) · 1.49 KB
/
example_usage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from datetime import datetime
from pprint import pprint
from qualtrics_mailer import (
QualtricsAccount,
QualtricsDistribution,
QualtricsMailingList
)
# set data center and API token
api_token = '[your account API token]'
data_center = '[your account data center name]'
# initialize Qualtrics Account object
account = QualtricsAccount(api_token, data_center)
# set library id, mailing list, and category name
library_id = '[valid library id for your account]'
mailing_list_name = 'Example Usage List Name'
category_name = 'Example Usage Category Name'
# initialize Qualtrics Mailing List object
mailing_list = QualtricsMailingList(
account,
library_id,
mailing_list_name,
category_name
)
# import example contact list from test folder
with open('example_mailing_list.csv') as fp:
mailing_list.import_contact_list_from_csv_file(fp)
# print mailing list's contact list to confirm proper import
pprint(mailing_list.contact_list)
# set message id, survey id, and email settings
message_id = '[valid message id for your account]'
survey_id = '[valid survey id for your account]'
send_date = datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ')
from_name = 'Example Usage From Name'
reply_email = '[email protected]'
subject = 'Example Usage Subject'
distribution = QualtricsDistribution(
mailing_list,
message_id,
survey_id,
send_date,
from_name,
reply_email,
subject,
)
# print survey-distribution details to confirm proper creation
pprint(distribution.details)