Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/sendgrid/helpers/mail/tracking_settings.py: 31%
49 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
1class TrackingSettings(object):
2 """Settings to track how recipients interact with your email."""
4 def __init__(self,
5 click_tracking=None,
6 open_tracking=None,
7 subscription_tracking=None,
8 ganalytics=None):
9 """Create a TrackingSettings object
11 :param click_tracking: Allows you to track whether a recipient clicked
12 a link in your email.
13 :type click_tracking: ClickTracking, optional
14 :param open_tracking: Allows you to track whether the email was opened
15 or not, but including a single pixel image in
16 the body of the content. When the pixel is
17 loaded, we can log that the email was opened.
18 :type open_tracking: OpenTracking, optional
19 :param subscription_tracking: Allows you to insert a subscription
20 management link at the bottom of the
21 text and html bodies of your email. If
22 you would like to specify the location
23 of the link within your email, you may
24 use the substitution_tag.
25 :type subscription_tracking: SubscriptionTracking, optional
26 :param ganalytics: Allows you to enable tracking provided by Google
27 Analytics.
28 :type ganalytics: Ganalytics, optional
29 """
30 self._click_tracking = None
31 self._open_tracking = None
32 self._subscription_tracking = None
33 self._ganalytics = None
35 if click_tracking is not None:
36 self._click_tracking = click_tracking
38 if open_tracking is not None:
39 self._open_tracking = open_tracking
41 if subscription_tracking is not None:
42 self._subscription_tracking = subscription_tracking
44 if ganalytics is not None:
45 self._ganalytics = ganalytics
47 @property
48 def click_tracking(self):
49 """Allows you to track whether a recipient clicked a link in your email.
51 :rtype: ClickTracking
52 """
53 return self._click_tracking
55 @click_tracking.setter
56 def click_tracking(self, value):
57 """Allows you to track whether a recipient clicked a link in your email.
59 :param value: Allows you to track whether a recipient clicked a link
60 in your email.
61 :type value: ClickTracking
62 """
63 self._click_tracking = value
65 @property
66 def open_tracking(self):
67 """Allows you to track whether a recipient opened your email.
69 :rtype: OpenTracking
70 """
71 return self._open_tracking
73 @open_tracking.setter
74 def open_tracking(self, value):
75 """Allows you to track whether a recipient opened your email.
77 :param value: Allows you to track whether a recipient opened your
78 email.
79 :type value: OpenTracking
80 """
81 self._open_tracking = value
83 @property
84 def subscription_tracking(self):
85 """Settings for the subscription management link.
87 :rtype: SubscriptionTracking
88 """
89 return self._subscription_tracking
91 @subscription_tracking.setter
92 def subscription_tracking(self, value):
93 """Settings for the subscription management link.
95 :param value: Settings for the subscription management link.
96 :type value: SubscriptionTracking
97 """
98 self._subscription_tracking = value
100 @property
101 def ganalytics(self):
102 """Settings for Google Analytics.
104 :rtype: Ganalytics
105 """
106 return self._ganalytics
108 @ganalytics.setter
109 def ganalytics(self, value):
110 """Settings for Google Analytics.
112 :param value: Settings for Google Analytics.
113 :type value: Ganalytics
114 """
115 self._ganalytics = value
117 def get(self):
118 """
119 Get a JSON-ready representation of this TrackingSettings.
121 :returns: This TrackingSettings, ready for use in a request body.
122 :rtype: dict
123 """
124 tracking_settings = {}
125 if self.click_tracking is not None:
126 tracking_settings["click_tracking"] = self.click_tracking.get()
127 if self.open_tracking is not None:
128 tracking_settings["open_tracking"] = self.open_tracking.get()
129 if self.subscription_tracking is not None:
130 tracking_settings[
131 "subscription_tracking"] = self.subscription_tracking.get()
132 if self.ganalytics is not None:
133 tracking_settings["ganalytics"] = self.ganalytics.get()
134 return tracking_settings