-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmailing_lists.py
More file actions
32 lines (21 loc) · 982 Bytes
/
mailing_lists.py
File metadata and controls
32 lines (21 loc) · 982 Bytes
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
from qualtrics_api_base import QualtricsAPIBase
import json
class MailingLists(QualtricsAPIBase):
def __init__(self, api_token, data_center, retries=0):
super(MailingLists, self).__init__(api_token, data_center, retries)
def update_contact(self, mailing_list_id, contact_id, embedded_data=''):
if not mailing_list_id:
raise ValueError("mailing_list_id cannot be empty")
if not contact_id:
raise ValueError("contact_id cannot be empty")
url = '{}{}/contacts/{}'.format(self._get_service_url(), mailing_list_id, contact_id)
data = {}
if embedded_data:
data.update({"embeddedData": embedded_data})
response = self.put(url, data=json.dumps(data), headers=self.get_headers())
if response.ok:
pass
else: response={"Error":"failed"}
return response.json()
def _get_service_url(self):
return self.get_base_url() + "mailinglists/"