Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/sendgrid/helpers/mail/open_tracking.py: 35%
27 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 OpenTracking(object):
2 """
3 Allows you to track whether the email was opened or not, by including a
4 single pixel image in the body of the content. When the pixel is loaded,
5 we log that the email was opened.
6 """
8 def __init__(self, enable=None, substitution_tag=None):
9 """Create an OpenTracking to track when your email is opened.
11 :param enable: If open tracking is enabled.
12 :type enable: boolean, optional
13 :param substitution_tag: Tag in body to be replaced by tracking pixel.
14 :type substitution_tag: OpenTrackingSubstitionTag, optional
15 """
16 self._enable = None
17 self._substitution_tag = None
19 if enable is not None:
20 self.enable = enable
22 if substitution_tag is not None:
23 self.substitution_tag = substitution_tag
25 @property
26 def enable(self):
27 """Indicates if this setting is enabled.
29 :rtype: boolean
30 """
31 return self._enable
33 @enable.setter
34 def enable(self, value):
35 """Indicates if this setting is enabled.
37 :param value: Indicates if this setting is enabled.
38 :type value: boolean
39 """
40 self._enable = value
42 @property
43 def substitution_tag(self):
44 """Allows you to specify a substitution tag that you can insert in the
45 body of your email at a location that you desire. This tag will be
46 replaced by the open tracking pixel.
48 :rtype: string
49 """
50 return self._substitution_tag
52 @substitution_tag.setter
53 def substitution_tag(self, value):
54 """Allows you to specify a substitution tag that you can insert in the
55 body of your email at a location that you desire. This tag will be
56 replaced by the open tracking pixel.
58 :param value: Allows you to specify a substitution tag that you can
59 insert in the body of your email at a location that you
60 desire. This tag will be replaced by the open tracking
61 pixel.
63 :type value: string
64 """
65 self._substitution_tag = value
67 def get(self):
68 """
69 Get a JSON-ready representation of this OpenTracking.
71 :returns: This OpenTracking, ready for use in a request body.
72 :rtype: dict
73 """
74 open_tracking = {}
75 if self.enable is not None:
76 open_tracking["enable"] = self.enable
78 if self.substitution_tag is not None:
79 open_tracking["substitution_tag"] = self.substitution_tag.get()
80 return open_tracking