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

1from .group_id import GroupId 

2from .groups_to_display import GroupsToDisplay 

3 

4 

5class Asm(object): 

6 """An object specifying unsubscribe behavior.""" 

7 

8 def __init__(self, group_id, groups_to_display=None): 

9 """Create an ASM with the given group_id and groups_to_display. 

10 

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 

18 

19 if group_id is not None: 

20 self.group_id = group_id 

21 

22 if groups_to_display is not None: 

23 self.groups_to_display = groups_to_display 

24 

25 @property 

26 def group_id(self): 

27 """The unsubscribe group to associate with this email. 

28 

29 :rtype: GroupId 

30 """ 

31 return self._group_id 

32 

33 @group_id.setter 

34 def group_id(self, value): 

35 """The unsubscribe group to associate with this email. 

36 

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) 

44 

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. 

49 

50 :rtype: GroupsToDisplay 

51 """ 

52 return self._groups_to_display 

53 

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. 

58 

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) 

66 

67 def get(self): 

68 """ 

69 Get a JSON-ready representation of this ASM object. 

70 

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() 

77 

78 if self.groups_to_display is not None: 

79 asm["groups_to_display"] = self.groups_to_display.get() 

80 return asm