Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/sendgrid/helpers/mail/header.py: 39%

34 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2023-07-17 14:22 -0600

1class Header(object): 

2 """A header to specify specific handling instructions for your email. 

3 

4 If the name or value contain Unicode characters, they must be properly 

5 encoded. You may not overwrite the following reserved headers: 

6 x-sg-id, x-sg-eid, received, dkim-signature, Content-Type, 

7 Content-Transfer-Encoding, To, From, Subject, Reply-To, CC, BCC 

8 """ 

9 

10 def __init__(self, key=None, value=None, p=None): 

11 """Create a Header. 

12 

13 :param key: The name of the header (e.g. "Date") 

14 :type key: string, optional 

15 :param value: The header's value (e.g. "2013-02-27 1:23:45 PM PDT") 

16 :type value: string, optional 

17 :param name: p is the Personalization object or Personalization object 

18 index 

19 :type name: Personalization, integer, optional 

20 """ 

21 self._key = None 

22 self._value = None 

23 self._personalization = None 

24 

25 if key is not None: 

26 self.key = key 

27 if value is not None: 

28 self.value = value 

29 if p is not None: 

30 self.personalization = p 

31 

32 @property 

33 def key(self): 

34 """The name of the header. 

35 

36 :rtype: string 

37 """ 

38 return self._key 

39 

40 @key.setter 

41 def key(self, value): 

42 """The name of the header. 

43 

44 :param value: The name of the header. 

45 :type value: string 

46 """ 

47 self._key = value 

48 

49 @property 

50 def value(self): 

51 """The value of the header. 

52 

53 :rtype: string 

54 """ 

55 return self._value 

56 

57 @value.setter 

58 def value(self, value): 

59 """The value of the header. 

60 

61 :param value: The value of the header. 

62 :type value: string 

63 """ 

64 self._value = value 

65 

66 @property 

67 def personalization(self): 

68 """The Personalization object or Personalization object index 

69 

70 :rtype: Personalization, integer 

71 """ 

72 return self._personalization 

73 

74 @personalization.setter 

75 def personalization(self, value): 

76 """The Personalization object or Personalization object index 

77 

78 :param value: The Personalization object or Personalization object 

79 index 

80 :type value: Personalization, integer 

81 """ 

82 self._personalization = value 

83 

84 def get(self): 

85 """ 

86 Get a JSON-ready representation of this Header. 

87 

88 :returns: This Header, ready for use in a request body. 

89 :rtype: dict 

90 """ 

91 header = {} 

92 if self.key is not None and self.value is not None: 

93 header[self.key] = self.value 

94 return header