OriTxnInfo.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class OriTxnInfo(object):
  6. def __init__(self):
  7. self._category_type = None
  8. self._category_value = None
  9. self._txn_info = None
  10. @property
  11. def category_type(self):
  12. return self._category_type
  13. @category_type.setter
  14. def category_type(self, value):
  15. self._category_type = value
  16. @property
  17. def category_value(self):
  18. return self._category_value
  19. @category_value.setter
  20. def category_value(self, value):
  21. self._category_value = value
  22. @property
  23. def txn_info(self):
  24. return self._txn_info
  25. @txn_info.setter
  26. def txn_info(self, value):
  27. self._txn_info = value
  28. def to_alipay_dict(self):
  29. params = dict()
  30. if self.category_type:
  31. if hasattr(self.category_type, 'to_alipay_dict'):
  32. params['category_type'] = self.category_type.to_alipay_dict()
  33. else:
  34. params['category_type'] = self.category_type
  35. if self.category_value:
  36. if hasattr(self.category_value, 'to_alipay_dict'):
  37. params['category_value'] = self.category_value.to_alipay_dict()
  38. else:
  39. params['category_value'] = self.category_value
  40. if self.txn_info:
  41. if hasattr(self.txn_info, 'to_alipay_dict'):
  42. params['txn_info'] = self.txn_info.to_alipay_dict()
  43. else:
  44. params['txn_info'] = self.txn_info
  45. return params
  46. @staticmethod
  47. def from_alipay_dict(d):
  48. if not d:
  49. return None
  50. o = OriTxnInfo()
  51. if 'category_type' in d:
  52. o.category_type = d['category_type']
  53. if 'category_value' in d:
  54. o.category_value = d['category_value']
  55. if 'txn_info' in d:
  56. o.txn_info = d['txn_info']
  57. return o