CodeInfo.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. from alipay.aop.api.domain.Scene import Scene
  6. class CodeInfo(object):
  7. def __init__(self):
  8. self._goto_url = None
  9. self._scene = None
  10. @property
  11. def goto_url(self):
  12. return self._goto_url
  13. @goto_url.setter
  14. def goto_url(self, value):
  15. self._goto_url = value
  16. @property
  17. def scene(self):
  18. return self._scene
  19. @scene.setter
  20. def scene(self, value):
  21. if isinstance(value, Scene):
  22. self._scene = value
  23. else:
  24. self._scene = Scene.from_alipay_dict(value)
  25. def to_alipay_dict(self):
  26. params = dict()
  27. if self.goto_url:
  28. if hasattr(self.goto_url, 'to_alipay_dict'):
  29. params['goto_url'] = self.goto_url.to_alipay_dict()
  30. else:
  31. params['goto_url'] = self.goto_url
  32. if self.scene:
  33. if hasattr(self.scene, 'to_alipay_dict'):
  34. params['scene'] = self.scene.to_alipay_dict()
  35. else:
  36. params['scene'] = self.scene
  37. return params
  38. @staticmethod
  39. def from_alipay_dict(d):
  40. if not d:
  41. return None
  42. o = CodeInfo()
  43. if 'goto_url' in d:
  44. o.goto_url = d['goto_url']
  45. if 'scene' in d:
  46. o.scene = d['scene']
  47. return o