AlipayMiniCardData.py 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class AlipayMiniCardData(object):
  6. def __init__(self):
  7. self._action_link = None
  8. self._action_text = None
  9. self._app_name = None
  10. self._biz_code = None
  11. self._card_type = None
  12. self._coupon_pic = None
  13. self._edit_text = None
  14. self._item_pic = None
  15. self._main_text = None
  16. self._sub_text = None
  17. @property
  18. def action_link(self):
  19. return self._action_link
  20. @action_link.setter
  21. def action_link(self, value):
  22. self._action_link = value
  23. @property
  24. def action_text(self):
  25. return self._action_text
  26. @action_text.setter
  27. def action_text(self, value):
  28. self._action_text = value
  29. @property
  30. def app_name(self):
  31. return self._app_name
  32. @app_name.setter
  33. def app_name(self, value):
  34. self._app_name = value
  35. @property
  36. def biz_code(self):
  37. return self._biz_code
  38. @biz_code.setter
  39. def biz_code(self, value):
  40. self._biz_code = value
  41. @property
  42. def card_type(self):
  43. return self._card_type
  44. @card_type.setter
  45. def card_type(self, value):
  46. self._card_type = value
  47. @property
  48. def coupon_pic(self):
  49. return self._coupon_pic
  50. @coupon_pic.setter
  51. def coupon_pic(self, value):
  52. self._coupon_pic = value
  53. @property
  54. def edit_text(self):
  55. return self._edit_text
  56. @edit_text.setter
  57. def edit_text(self, value):
  58. self._edit_text = value
  59. @property
  60. def item_pic(self):
  61. return self._item_pic
  62. @item_pic.setter
  63. def item_pic(self, value):
  64. self._item_pic = value
  65. @property
  66. def main_text(self):
  67. return self._main_text
  68. @main_text.setter
  69. def main_text(self, value):
  70. self._main_text = value
  71. @property
  72. def sub_text(self):
  73. return self._sub_text
  74. @sub_text.setter
  75. def sub_text(self, value):
  76. self._sub_text = value
  77. def to_alipay_dict(self):
  78. params = dict()
  79. if self.action_link:
  80. if hasattr(self.action_link, 'to_alipay_dict'):
  81. params['action_link'] = self.action_link.to_alipay_dict()
  82. else:
  83. params['action_link'] = self.action_link
  84. if self.action_text:
  85. if hasattr(self.action_text, 'to_alipay_dict'):
  86. params['action_text'] = self.action_text.to_alipay_dict()
  87. else:
  88. params['action_text'] = self.action_text
  89. if self.app_name:
  90. if hasattr(self.app_name, 'to_alipay_dict'):
  91. params['app_name'] = self.app_name.to_alipay_dict()
  92. else:
  93. params['app_name'] = self.app_name
  94. if self.biz_code:
  95. if hasattr(self.biz_code, 'to_alipay_dict'):
  96. params['biz_code'] = self.biz_code.to_alipay_dict()
  97. else:
  98. params['biz_code'] = self.biz_code
  99. if self.card_type:
  100. if hasattr(self.card_type, 'to_alipay_dict'):
  101. params['card_type'] = self.card_type.to_alipay_dict()
  102. else:
  103. params['card_type'] = self.card_type
  104. if self.coupon_pic:
  105. if hasattr(self.coupon_pic, 'to_alipay_dict'):
  106. params['coupon_pic'] = self.coupon_pic.to_alipay_dict()
  107. else:
  108. params['coupon_pic'] = self.coupon_pic
  109. if self.edit_text:
  110. if hasattr(self.edit_text, 'to_alipay_dict'):
  111. params['edit_text'] = self.edit_text.to_alipay_dict()
  112. else:
  113. params['edit_text'] = self.edit_text
  114. if self.item_pic:
  115. if hasattr(self.item_pic, 'to_alipay_dict'):
  116. params['item_pic'] = self.item_pic.to_alipay_dict()
  117. else:
  118. params['item_pic'] = self.item_pic
  119. if self.main_text:
  120. if hasattr(self.main_text, 'to_alipay_dict'):
  121. params['main_text'] = self.main_text.to_alipay_dict()
  122. else:
  123. params['main_text'] = self.main_text
  124. if self.sub_text:
  125. if hasattr(self.sub_text, 'to_alipay_dict'):
  126. params['sub_text'] = self.sub_text.to_alipay_dict()
  127. else:
  128. params['sub_text'] = self.sub_text
  129. return params
  130. @staticmethod
  131. def from_alipay_dict(d):
  132. if not d:
  133. return None
  134. o = AlipayMiniCardData()
  135. if 'action_link' in d:
  136. o.action_link = d['action_link']
  137. if 'action_text' in d:
  138. o.action_text = d['action_text']
  139. if 'app_name' in d:
  140. o.app_name = d['app_name']
  141. if 'biz_code' in d:
  142. o.biz_code = d['biz_code']
  143. if 'card_type' in d:
  144. o.card_type = d['card_type']
  145. if 'coupon_pic' in d:
  146. o.coupon_pic = d['coupon_pic']
  147. if 'edit_text' in d:
  148. o.edit_text = d['edit_text']
  149. if 'item_pic' in d:
  150. o.item_pic = d['item_pic']
  151. if 'main_text' in d:
  152. o.main_text = d['main_text']
  153. if 'sub_text' in d:
  154. o.sub_text = d['sub_text']
  155. return o