PresetPayToolInfo.py 1.8 KB

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