DataEnumValue.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.FilterTag import FilterTag
  6. class DataEnumValue(object):
  7. def __init__(self):
  8. self._filter_tags = None
  9. self._label = None
  10. self._value = None
  11. @property
  12. def filter_tags(self):
  13. return self._filter_tags
  14. @filter_tags.setter
  15. def filter_tags(self, value):
  16. if isinstance(value, list):
  17. self._filter_tags = list()
  18. for i in value:
  19. if isinstance(i, FilterTag):
  20. self._filter_tags.append(i)
  21. else:
  22. self._filter_tags.append(FilterTag.from_alipay_dict(i))
  23. @property
  24. def label(self):
  25. return self._label
  26. @label.setter
  27. def label(self, value):
  28. self._label = value
  29. @property
  30. def value(self):
  31. return self._value
  32. @value.setter
  33. def value(self, value):
  34. self._value = value
  35. def to_alipay_dict(self):
  36. params = dict()
  37. if self.filter_tags:
  38. if isinstance(self.filter_tags, list):
  39. for i in range(0, len(self.filter_tags)):
  40. element = self.filter_tags[i]
  41. if hasattr(element, 'to_alipay_dict'):
  42. self.filter_tags[i] = element.to_alipay_dict()
  43. if hasattr(self.filter_tags, 'to_alipay_dict'):
  44. params['filter_tags'] = self.filter_tags.to_alipay_dict()
  45. else:
  46. params['filter_tags'] = self.filter_tags
  47. if self.label:
  48. if hasattr(self.label, 'to_alipay_dict'):
  49. params['label'] = self.label.to_alipay_dict()
  50. else:
  51. params['label'] = self.label
  52. if self.value:
  53. if hasattr(self.value, 'to_alipay_dict'):
  54. params['value'] = self.value.to_alipay_dict()
  55. else:
  56. params['value'] = self.value
  57. return params
  58. @staticmethod
  59. def from_alipay_dict(d):
  60. if not d:
  61. return None
  62. o = DataEnumValue()
  63. if 'filter_tags' in d:
  64. o.filter_tags = d['filter_tags']
  65. if 'label' in d:
  66. o.label = d['label']
  67. if 'value' in d:
  68. o.value = d['value']
  69. return o