FengdieTemplate.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class FengdieTemplate(object):
  6. def __init__(self):
  7. self._id = None
  8. self._maintainer = None
  9. self._name = None
  10. self._snapshot = None
  11. self._summary = None
  12. self._title = None
  13. @property
  14. def id(self):
  15. return self._id
  16. @id.setter
  17. def id(self, value):
  18. self._id = value
  19. @property
  20. def maintainer(self):
  21. return self._maintainer
  22. @maintainer.setter
  23. def maintainer(self, value):
  24. if isinstance(value, list):
  25. self._maintainer = list()
  26. for i in value:
  27. self._maintainer.append(i)
  28. @property
  29. def name(self):
  30. return self._name
  31. @name.setter
  32. def name(self, value):
  33. self._name = value
  34. @property
  35. def snapshot(self):
  36. return self._snapshot
  37. @snapshot.setter
  38. def snapshot(self, value):
  39. self._snapshot = value
  40. @property
  41. def summary(self):
  42. return self._summary
  43. @summary.setter
  44. def summary(self, value):
  45. self._summary = value
  46. @property
  47. def title(self):
  48. return self._title
  49. @title.setter
  50. def title(self, value):
  51. self._title = value
  52. def to_alipay_dict(self):
  53. params = dict()
  54. if self.id:
  55. if hasattr(self.id, 'to_alipay_dict'):
  56. params['id'] = self.id.to_alipay_dict()
  57. else:
  58. params['id'] = self.id
  59. if self.maintainer:
  60. if isinstance(self.maintainer, list):
  61. for i in range(0, len(self.maintainer)):
  62. element = self.maintainer[i]
  63. if hasattr(element, 'to_alipay_dict'):
  64. self.maintainer[i] = element.to_alipay_dict()
  65. if hasattr(self.maintainer, 'to_alipay_dict'):
  66. params['maintainer'] = self.maintainer.to_alipay_dict()
  67. else:
  68. params['maintainer'] = self.maintainer
  69. if self.name:
  70. if hasattr(self.name, 'to_alipay_dict'):
  71. params['name'] = self.name.to_alipay_dict()
  72. else:
  73. params['name'] = self.name
  74. if self.snapshot:
  75. if hasattr(self.snapshot, 'to_alipay_dict'):
  76. params['snapshot'] = self.snapshot.to_alipay_dict()
  77. else:
  78. params['snapshot'] = self.snapshot
  79. if self.summary:
  80. if hasattr(self.summary, 'to_alipay_dict'):
  81. params['summary'] = self.summary.to_alipay_dict()
  82. else:
  83. params['summary'] = self.summary
  84. if self.title:
  85. if hasattr(self.title, 'to_alipay_dict'):
  86. params['title'] = self.title.to_alipay_dict()
  87. else:
  88. params['title'] = self.title
  89. return params
  90. @staticmethod
  91. def from_alipay_dict(d):
  92. if not d:
  93. return None
  94. o = FengdieTemplate()
  95. if 'id' in d:
  96. o.id = d['id']
  97. if 'maintainer' in d:
  98. o.maintainer = d['maintainer']
  99. if 'name' in d:
  100. o.name = d['name']
  101. if 'snapshot' in d:
  102. o.snapshot = d['snapshot']
  103. if 'summary' in d:
  104. o.summary = d['summary']
  105. if 'title' in d:
  106. o.title = d['title']
  107. return o