LifeLabel.py 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. from alipay.aop.api.domain.Option import Option
  6. class LifeLabel(object):
  7. def __init__(self):
  8. self._biz = None
  9. self._category = None
  10. self._data_type = None
  11. self._label_code = None
  12. self._label_id = None
  13. self._label_name = None
  14. self._operator = None
  15. self._options = None
  16. self._type = None
  17. @property
  18. def biz(self):
  19. return self._biz
  20. @biz.setter
  21. def biz(self, value):
  22. self._biz = value
  23. @property
  24. def category(self):
  25. return self._category
  26. @category.setter
  27. def category(self, value):
  28. self._category = value
  29. @property
  30. def data_type(self):
  31. return self._data_type
  32. @data_type.setter
  33. def data_type(self, value):
  34. self._data_type = value
  35. @property
  36. def label_code(self):
  37. return self._label_code
  38. @label_code.setter
  39. def label_code(self, value):
  40. self._label_code = value
  41. @property
  42. def label_id(self):
  43. return self._label_id
  44. @label_id.setter
  45. def label_id(self, value):
  46. self._label_id = value
  47. @property
  48. def label_name(self):
  49. return self._label_name
  50. @label_name.setter
  51. def label_name(self, value):
  52. self._label_name = value
  53. @property
  54. def operator(self):
  55. return self._operator
  56. @operator.setter
  57. def operator(self, value):
  58. self._operator = value
  59. @property
  60. def options(self):
  61. return self._options
  62. @options.setter
  63. def options(self, value):
  64. if isinstance(value, list):
  65. self._options = list()
  66. for i in value:
  67. if isinstance(i, Option):
  68. self._options.append(i)
  69. else:
  70. self._options.append(Option.from_alipay_dict(i))
  71. @property
  72. def type(self):
  73. return self._type
  74. @type.setter
  75. def type(self, value):
  76. self._type = value
  77. def to_alipay_dict(self):
  78. params = dict()
  79. if self.biz:
  80. if hasattr(self.biz, 'to_alipay_dict'):
  81. params['biz'] = self.biz.to_alipay_dict()
  82. else:
  83. params['biz'] = self.biz
  84. if self.category:
  85. if hasattr(self.category, 'to_alipay_dict'):
  86. params['category'] = self.category.to_alipay_dict()
  87. else:
  88. params['category'] = self.category
  89. if self.data_type:
  90. if hasattr(self.data_type, 'to_alipay_dict'):
  91. params['data_type'] = self.data_type.to_alipay_dict()
  92. else:
  93. params['data_type'] = self.data_type
  94. if self.label_code:
  95. if hasattr(self.label_code, 'to_alipay_dict'):
  96. params['label_code'] = self.label_code.to_alipay_dict()
  97. else:
  98. params['label_code'] = self.label_code
  99. if self.label_id:
  100. if hasattr(self.label_id, 'to_alipay_dict'):
  101. params['label_id'] = self.label_id.to_alipay_dict()
  102. else:
  103. params['label_id'] = self.label_id
  104. if self.label_name:
  105. if hasattr(self.label_name, 'to_alipay_dict'):
  106. params['label_name'] = self.label_name.to_alipay_dict()
  107. else:
  108. params['label_name'] = self.label_name
  109. if self.operator:
  110. if hasattr(self.operator, 'to_alipay_dict'):
  111. params['operator'] = self.operator.to_alipay_dict()
  112. else:
  113. params['operator'] = self.operator
  114. if self.options:
  115. if isinstance(self.options, list):
  116. for i in range(0, len(self.options)):
  117. element = self.options[i]
  118. if hasattr(element, 'to_alipay_dict'):
  119. self.options[i] = element.to_alipay_dict()
  120. if hasattr(self.options, 'to_alipay_dict'):
  121. params['options'] = self.options.to_alipay_dict()
  122. else:
  123. params['options'] = self.options
  124. if self.type:
  125. if hasattr(self.type, 'to_alipay_dict'):
  126. params['type'] = self.type.to_alipay_dict()
  127. else:
  128. params['type'] = self.type
  129. return params
  130. @staticmethod
  131. def from_alipay_dict(d):
  132. if not d:
  133. return None
  134. o = LifeLabel()
  135. if 'biz' in d:
  136. o.biz = d['biz']
  137. if 'category' in d:
  138. o.category = d['category']
  139. if 'data_type' in d:
  140. o.data_type = d['data_type']
  141. if 'label_code' in d:
  142. o.label_code = d['label_code']
  143. if 'label_id' in d:
  144. o.label_id = d['label_id']
  145. if 'label_name' in d:
  146. o.label_name = d['label_name']
  147. if 'operator' in d:
  148. o.operator = d['operator']
  149. if 'options' in d:
  150. o.options = d['options']
  151. if 'type' in d:
  152. o.type = d['type']
  153. return o