TemplateActionInfoDTO.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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.TemplateActionMiniAppUrlDTO import TemplateActionMiniAppUrlDTO
  6. class TemplateActionInfoDTO(object):
  7. def __init__(self):
  8. self._code = None
  9. self._mini_app_url = None
  10. self._text = None
  11. self._url = None
  12. self._url_type = None
  13. @property
  14. def code(self):
  15. return self._code
  16. @code.setter
  17. def code(self, value):
  18. self._code = value
  19. @property
  20. def mini_app_url(self):
  21. return self._mini_app_url
  22. @mini_app_url.setter
  23. def mini_app_url(self, value):
  24. if isinstance(value, TemplateActionMiniAppUrlDTO):
  25. self._mini_app_url = value
  26. else:
  27. self._mini_app_url = TemplateActionMiniAppUrlDTO.from_alipay_dict(value)
  28. @property
  29. def text(self):
  30. return self._text
  31. @text.setter
  32. def text(self, value):
  33. self._text = value
  34. @property
  35. def url(self):
  36. return self._url
  37. @url.setter
  38. def url(self, value):
  39. self._url = value
  40. @property
  41. def url_type(self):
  42. return self._url_type
  43. @url_type.setter
  44. def url_type(self, value):
  45. self._url_type = value
  46. def to_alipay_dict(self):
  47. params = dict()
  48. if self.code:
  49. if hasattr(self.code, 'to_alipay_dict'):
  50. params['code'] = self.code.to_alipay_dict()
  51. else:
  52. params['code'] = self.code
  53. if self.mini_app_url:
  54. if hasattr(self.mini_app_url, 'to_alipay_dict'):
  55. params['mini_app_url'] = self.mini_app_url.to_alipay_dict()
  56. else:
  57. params['mini_app_url'] = self.mini_app_url
  58. if self.text:
  59. if hasattr(self.text, 'to_alipay_dict'):
  60. params['text'] = self.text.to_alipay_dict()
  61. else:
  62. params['text'] = self.text
  63. if self.url:
  64. if hasattr(self.url, 'to_alipay_dict'):
  65. params['url'] = self.url.to_alipay_dict()
  66. else:
  67. params['url'] = self.url
  68. if self.url_type:
  69. if hasattr(self.url_type, 'to_alipay_dict'):
  70. params['url_type'] = self.url_type.to_alipay_dict()
  71. else:
  72. params['url_type'] = self.url_type
  73. return params
  74. @staticmethod
  75. def from_alipay_dict(d):
  76. if not d:
  77. return None
  78. o = TemplateActionInfoDTO()
  79. if 'code' in d:
  80. o.code = d['code']
  81. if 'mini_app_url' in d:
  82. o.mini_app_url = d['mini_app_url']
  83. if 'text' in d:
  84. o.text = d['text']
  85. if 'url' in d:
  86. o.url = d['url']
  87. if 'url_type' in d:
  88. o.url_type = d['url_type']
  89. return o