forked from sendgrid/sendgrid-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtracking_settings.py
134 lines (110 loc) · 4.68 KB
/
tracking_settings.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
class TrackingSettings(object):
"""Settings to track how recipients interact with your email."""
def __init__(self,
click_tracking=None,
open_tracking=None,
subscription_tracking=None,
ganalytics=None):
"""Create a TrackingSettings object
:param click_tracking: Allows you to track whether a recipient clicked
a link in your email.
:type click_tracking: ClickTracking, optional
:param open_tracking: Allows you to track whether the email was opened
or not, but including a single pixel image in
the body of the content. When the pixel is
loaded, we can log that the email was opened.
:type open_tracking: OpenTracking, optional
:param subscription_tracking: Allows you to insert a subscription
management link at the bottom of the
text and html bodies of your email. If
you would like to specify the location
of the link within your email, you may
use the substitution_tag.
:type subscription_tracking: SubscriptionTracking, optional
:param ganalytics: Allows you to enable tracking provided by Google
Analytics.
:type ganalytics: Ganalytics, optional
"""
self._click_tracking = None
self._open_tracking = None
self._subscription_tracking = None
self._ganalytics = None
if click_tracking is not None:
self._click_tracking = click_tracking
if open_tracking is not None:
self._open_tracking = open_tracking
if subscription_tracking is not None:
self._subscription_tracking = subscription_tracking
if ganalytics is not None:
self._ganalytics = ganalytics
@property
def click_tracking(self):
"""Allows you to track whether a recipient clicked a link in your email.
:rtype: ClickTracking
"""
return self._click_tracking
@click_tracking.setter
def click_tracking(self, value):
"""Allows you to track whether a recipient clicked a link in your email.
:param value: Allows you to track whether a recipient clicked a link
in your email.
:type value: ClickTracking
"""
self._click_tracking = value
@property
def open_tracking(self):
"""Allows you to track whether a recipient opened your email.
:rtype: OpenTracking
"""
return self._open_tracking
@open_tracking.setter
def open_tracking(self, value):
"""Allows you to track whether a recipient opened your email.
:param value: Allows you to track whether a recipient opened your
email.
:type value: OpenTracking
"""
self._open_tracking = value
@property
def subscription_tracking(self):
"""Settings for the subscription management link.
:rtype: SubscriptionTracking
"""
return self._subscription_tracking
@subscription_tracking.setter
def subscription_tracking(self, value):
"""Settings for the subscription management link.
:param value: Settings for the subscription management link.
:type value: SubscriptionTracking
"""
self._subscription_tracking = value
@property
def ganalytics(self):
"""Settings for Google Analytics.
:rtype: Ganalytics
"""
return self._ganalytics
@ganalytics.setter
def ganalytics(self, value):
"""Settings for Google Analytics.
:param value: Settings for Google Analytics.
:type value: Ganalytics
"""
self._ganalytics = value
def get(self):
"""
Get a JSON-ready representation of this TrackingSettings.
:returns: This TrackingSettings, ready for use in a request body.
:rtype: dict
"""
tracking_settings = {}
if self.click_tracking is not None:
tracking_settings["click_tracking"] = self.click_tracking.get()
if self.open_tracking is not None:
tracking_settings["open_tracking"] = self.open_tracking.get()
if self.subscription_tracking is not None:
tracking_settings[
"subscription_tracking"] = self.subscription_tracking.get()
if self.ganalytics is not None:
tracking_settings["ganalytics"] = self.ganalytics.get()
return tracking_settings