DevicePushPayload.py 1.8 KB

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