Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/sendgrid/helpers/mail/asm.py: 32%
33 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
1from .group_id import GroupId
2from .groups_to_display import GroupsToDisplay
5class Asm(object):
6 """An object specifying unsubscribe behavior."""
8 def __init__(self, group_id, groups_to_display=None):
9 """Create an ASM with the given group_id and groups_to_display.
11 :param group_id: ID of an unsubscribe group
12 :type group_id: GroupId, int, required
13 :param groups_to_display: Unsubscribe groups to display
14 :type groups_to_display: GroupsToDisplay, list(int), optional
15 """
16 self._group_id = None
17 self._groups_to_display = None
19 if group_id is not None:
20 self.group_id = group_id
22 if groups_to_display is not None:
23 self.groups_to_display = groups_to_display
25 @property
26 def group_id(self):
27 """The unsubscribe group to associate with this email.
29 :rtype: GroupId
30 """
31 return self._group_id
33 @group_id.setter
34 def group_id(self, value):
35 """The unsubscribe group to associate with this email.
37 :param value: ID of an unsubscribe group
38 :type value: GroupId, int, required
39 """
40 if isinstance(value, GroupId):
41 self._group_id = value
42 else:
43 self._group_id = GroupId(value)
45 @property
46 def groups_to_display(self):
47 """The unsubscribe groups that you would like to be displayed on the
48 unsubscribe preferences page. Max of 25 groups.
50 :rtype: GroupsToDisplay
51 """
52 return self._groups_to_display
54 @groups_to_display.setter
55 def groups_to_display(self, value):
56 """An array containing the unsubscribe groups that you would like to
57 be displayed on the unsubscribe preferences page. Max of 25 groups.
59 :param groups_to_display: Unsubscribe groups to display
60 :type groups_to_display: GroupsToDisplay, list(int), optional
61 """
62 if isinstance(value, GroupsToDisplay):
63 self._groups_to_display = value
64 else:
65 self._groups_to_display = GroupsToDisplay(value)
67 def get(self):
68 """
69 Get a JSON-ready representation of this ASM object.
71 :returns: This ASM object, ready for use in a request body.
72 :rtype: dict
73 """
74 asm = {}
75 if self.group_id is not None:
76 asm["group_id"] = self.group_id.get()
78 if self.groups_to_display is not None:
79 asm["groups_to_display"] = self.groups_to_display.get()
80 return asm