WhitehatInfo.py 1.7 KB

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