aboutsummaryrefslogtreecommitdiff
path: root/.venv/lib/python3.12/site-packages/sendgrid/helpers/mail/open_tracking.py
blob: 7124a2e661180def49734a1db75eae48cea2cfd2 (about) (plain)
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
class OpenTracking(object):
    """
    Allows you to track whether the email was opened or not, by including a
    single pixel image in the body of the content. When the pixel is loaded,
    we log that the email was opened.
    """

    def __init__(self, enable=None, substitution_tag=None):
        """Create an OpenTracking to track when your email is opened.

        :param enable: If open tracking is enabled.
        :type enable: boolean, optional
        :param substitution_tag: Tag in body to be replaced by tracking pixel.
        :type substitution_tag: OpenTrackingSubstitionTag, optional
        """
        self._enable = None
        self._substitution_tag = None

        if enable is not None:
            self.enable = enable

        if substitution_tag is not None:
            self.substitution_tag = substitution_tag

    @property
    def enable(self):
        """Indicates if this setting is enabled.

        :rtype: boolean
        """
        return self._enable

    @enable.setter
    def enable(self, value):
        """Indicates if this setting is enabled.

        :param value: Indicates if this setting is enabled.
        :type value: boolean
        """
        self._enable = value

    @property
    def substitution_tag(self):
        """Allows you to specify a substitution tag that you can insert in the
        body of your email at a location that you desire. This tag will be
        replaced by the open tracking pixel.

        :rtype: string
        """
        return self._substitution_tag

    @substitution_tag.setter
    def substitution_tag(self, value):
        """Allows you to specify a substitution tag that you can insert in the
        body of your email at a location that you desire. This tag will be
        replaced by the open tracking pixel.

        :param value: Allows you to specify a substitution tag that you can
                      insert in the body of your email at a location that you
                      desire. This tag will be replaced by the open tracking
                      pixel.

        :type value: string
        """
        self._substitution_tag = value

    def get(self):
        """
        Get a JSON-ready representation of this OpenTracking.

        :returns: This OpenTracking, ready for use in a request body.
        :rtype: dict
        """
        open_tracking = {}
        if self.enable is not None:
            open_tracking["enable"] = self.enable

        if self.substitution_tag is not None:
            open_tracking["substitution_tag"] = self.substitution_tag.get()
        return open_tracking