SubButton.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class SubButton(object):
  6. def __init__(self):
  7. self._action_param = None
  8. self._action_type = None
  9. self._icon = None
  10. self._name = None
  11. @property
  12. def action_param(self):
  13. return self._action_param
  14. @action_param.setter
  15. def action_param(self, value):
  16. self._action_param = value
  17. @property
  18. def action_type(self):
  19. return self._action_type
  20. @action_type.setter
  21. def action_type(self, value):
  22. self._action_type = value
  23. @property
  24. def icon(self):
  25. return self._icon
  26. @icon.setter
  27. def icon(self, value):
  28. self._icon = value
  29. @property
  30. def name(self):
  31. return self._name
  32. @name.setter
  33. def name(self, value):
  34. self._name = value
  35. def to_alipay_dict(self):
  36. params = dict()
  37. if self.action_param:
  38. if hasattr(self.action_param, 'to_alipay_dict'):
  39. params['action_param'] = self.action_param.to_alipay_dict()
  40. else:
  41. params['action_param'] = self.action_param
  42. if self.action_type:
  43. if hasattr(self.action_type, 'to_alipay_dict'):
  44. params['action_type'] = self.action_type.to_alipay_dict()
  45. else:
  46. params['action_type'] = self.action_type
  47. if self.icon:
  48. if hasattr(self.icon, 'to_alipay_dict'):
  49. params['icon'] = self.icon.to_alipay_dict()
  50. else:
  51. params['icon'] = self.icon
  52. if self.name:
  53. if hasattr(self.name, 'to_alipay_dict'):
  54. params['name'] = self.name.to_alipay_dict()
  55. else:
  56. params['name'] = self.name
  57. return params
  58. @staticmethod
  59. def from_alipay_dict(d):
  60. if not d:
  61. return None
  62. o = SubButton()
  63. if 'action_param' in d:
  64. o.action_param = d['action_param']
  65. if 'action_type' in d:
  66. o.action_type = d['action_type']
  67. if 'icon' in d:
  68. o.icon = d['icon']
  69. if 'name' in d:
  70. o.name = d['name']
  71. return o