BeaconTemplate.py 1.3 KB

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