AlipayOpenPublicMessageSingleSendModel.py 1.5 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.Template import Template
  6. class AlipayOpenPublicMessageSingleSendModel(object):
  7. def __init__(self):
  8. self._template = None
  9. self._to_user_id = None
  10. @property
  11. def template(self):
  12. return self._template
  13. @template.setter
  14. def template(self, value):
  15. if isinstance(value, Template):
  16. self._template = value
  17. else:
  18. self._template = Template.from_alipay_dict(value)
  19. @property
  20. def to_user_id(self):
  21. return self._to_user_id
  22. @to_user_id.setter
  23. def to_user_id(self, value):
  24. self._to_user_id = value
  25. def to_alipay_dict(self):
  26. params = dict()
  27. if self.template:
  28. if hasattr(self.template, 'to_alipay_dict'):
  29. params['template'] = self.template.to_alipay_dict()
  30. else:
  31. params['template'] = self.template
  32. if self.to_user_id:
  33. if hasattr(self.to_user_id, 'to_alipay_dict'):
  34. params['to_user_id'] = self.to_user_id.to_alipay_dict()
  35. else:
  36. params['to_user_id'] = self.to_user_id
  37. return params
  38. @staticmethod
  39. def from_alipay_dict(d):
  40. if not d:
  41. return None
  42. o = AlipayOpenPublicMessageSingleSendModel()
  43. if 'template' in d:
  44. o.template = d['template']
  45. if 'to_user_id' in d:
  46. o.to_user_id = d['to_user_id']
  47. return o