KbAdvertAdvContentResponse.py 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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.KbAdvertContentCodec import KbAdvertContentCodec
  6. from alipay.aop.api.domain.KbAdvertContentPassword import KbAdvertContentPassword
  7. from alipay.aop.api.domain.KbAdvertContentShareCode import KbAdvertContentShareCode
  8. from alipay.aop.api.domain.KbAdvertContentShortLink import KbAdvertContentShortLink
  9. class KbAdvertAdvContentResponse(object):
  10. def __init__(self):
  11. self._content_codec = None
  12. self._content_password = None
  13. self._content_share_code = None
  14. self._content_short_link = None
  15. self._content_type = None
  16. @property
  17. def content_codec(self):
  18. return self._content_codec
  19. @content_codec.setter
  20. def content_codec(self, value):
  21. if isinstance(value, KbAdvertContentCodec):
  22. self._content_codec = value
  23. else:
  24. self._content_codec = KbAdvertContentCodec.from_alipay_dict(value)
  25. @property
  26. def content_password(self):
  27. return self._content_password
  28. @content_password.setter
  29. def content_password(self, value):
  30. if isinstance(value, KbAdvertContentPassword):
  31. self._content_password = value
  32. else:
  33. self._content_password = KbAdvertContentPassword.from_alipay_dict(value)
  34. @property
  35. def content_share_code(self):
  36. return self._content_share_code
  37. @content_share_code.setter
  38. def content_share_code(self, value):
  39. if isinstance(value, list):
  40. self._content_share_code = list()
  41. for i in value:
  42. if isinstance(i, KbAdvertContentShareCode):
  43. self._content_share_code.append(i)
  44. else:
  45. self._content_share_code.append(KbAdvertContentShareCode.from_alipay_dict(i))
  46. @property
  47. def content_short_link(self):
  48. return self._content_short_link
  49. @content_short_link.setter
  50. def content_short_link(self, value):
  51. if isinstance(value, KbAdvertContentShortLink):
  52. self._content_short_link = value
  53. else:
  54. self._content_short_link = KbAdvertContentShortLink.from_alipay_dict(value)
  55. @property
  56. def content_type(self):
  57. return self._content_type
  58. @content_type.setter
  59. def content_type(self, value):
  60. self._content_type = value
  61. def to_alipay_dict(self):
  62. params = dict()
  63. if self.content_codec:
  64. if hasattr(self.content_codec, 'to_alipay_dict'):
  65. params['content_codec'] = self.content_codec.to_alipay_dict()
  66. else:
  67. params['content_codec'] = self.content_codec
  68. if self.content_password:
  69. if hasattr(self.content_password, 'to_alipay_dict'):
  70. params['content_password'] = self.content_password.to_alipay_dict()
  71. else:
  72. params['content_password'] = self.content_password
  73. if self.content_share_code:
  74. if isinstance(self.content_share_code, list):
  75. for i in range(0, len(self.content_share_code)):
  76. element = self.content_share_code[i]
  77. if hasattr(element, 'to_alipay_dict'):
  78. self.content_share_code[i] = element.to_alipay_dict()
  79. if hasattr(self.content_share_code, 'to_alipay_dict'):
  80. params['content_share_code'] = self.content_share_code.to_alipay_dict()
  81. else:
  82. params['content_share_code'] = self.content_share_code
  83. if self.content_short_link:
  84. if hasattr(self.content_short_link, 'to_alipay_dict'):
  85. params['content_short_link'] = self.content_short_link.to_alipay_dict()
  86. else:
  87. params['content_short_link'] = self.content_short_link
  88. if self.content_type:
  89. if hasattr(self.content_type, 'to_alipay_dict'):
  90. params['content_type'] = self.content_type.to_alipay_dict()
  91. else:
  92. params['content_type'] = self.content_type
  93. return params
  94. @staticmethod
  95. def from_alipay_dict(d):
  96. if not d:
  97. return None
  98. o = KbAdvertAdvContentResponse()
  99. if 'content_codec' in d:
  100. o.content_codec = d['content_codec']
  101. if 'content_password' in d:
  102. o.content_password = d['content_password']
  103. if 'content_share_code' in d:
  104. o.content_share_code = d['content_share_code']
  105. if 'content_short_link' in d:
  106. o.content_short_link = d['content_short_link']
  107. if 'content_type' in d:
  108. o.content_type = d['content_type']
  109. return o