NewsfeedMediaImg.py 1.6 KB

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