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

25 statements  

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

1class Section(object): 

2 """A block section of code to be used as a substitution.""" 

3 

4 def __init__(self, key=None, value=None): 

5 """Create a section with the given key and value. 

6 

7 :param key: section of code key 

8 :type key: string 

9 :param value: section of code value 

10 :type value: string 

11 """ 

12 self._key = None 

13 self._value = None 

14 

15 if key is not None: 

16 self.key = key 

17 if value is not None: 

18 self.value = value 

19 

20 @property 

21 def key(self): 

22 """A section of code's key. 

23 

24 :rtype key: string 

25 """ 

26 return self._key 

27 

28 @key.setter 

29 def key(self, value): 

30 """A section of code's key. 

31 

32 :param key: section of code key 

33 :type key: string 

34 """ 

35 self._key = value 

36 

37 @property 

38 def value(self): 

39 """A section of code's value. 

40 

41 :rtype: string 

42 """ 

43 return self._value 

44 

45 @value.setter 

46 def value(self, value): 

47 """A section of code's value. 

48 

49 :param value: A section of code's value. 

50 :type value: string 

51 """ 

52 self._value = value 

53 

54 def get(self): 

55 """ 

56 Get a JSON-ready representation of this Section. 

57 

58 :returns: This Section, ready for use in a request body. 

59 :rtype: dict 

60 """ 

61 section = {} 

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

63 section[self.key] = self.value 

64 return section