VoucherTermInfo.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class VoucherTermInfo(object):
  6. def __init__(self):
  7. self._descriptions = None
  8. self._title = None
  9. @property
  10. def descriptions(self):
  11. return self._descriptions
  12. @descriptions.setter
  13. def descriptions(self, value):
  14. if isinstance(value, list):
  15. self._descriptions = list()
  16. for i in value:
  17. self._descriptions.append(i)
  18. @property
  19. def title(self):
  20. return self._title
  21. @title.setter
  22. def title(self, value):
  23. self._title = value
  24. def to_alipay_dict(self):
  25. params = dict()
  26. if self.descriptions:
  27. if isinstance(self.descriptions, list):
  28. for i in range(0, len(self.descriptions)):
  29. element = self.descriptions[i]
  30. if hasattr(element, 'to_alipay_dict'):
  31. self.descriptions[i] = element.to_alipay_dict()
  32. if hasattr(self.descriptions, 'to_alipay_dict'):
  33. params['descriptions'] = self.descriptions.to_alipay_dict()
  34. else:
  35. params['descriptions'] = self.descriptions
  36. if self.title:
  37. if hasattr(self.title, 'to_alipay_dict'):
  38. params['title'] = self.title.to_alipay_dict()
  39. else:
  40. params['title'] = self.title
  41. return params
  42. @staticmethod
  43. def from_alipay_dict(d):
  44. if not d:
  45. return None
  46. o = VoucherTermInfo()
  47. if 'descriptions' in d:
  48. o.descriptions = d['descriptions']
  49. if 'title' in d:
  50. o.title = d['title']
  51. return o