AlipayContract.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class AlipayContract(object):
  6. def __init__(self):
  7. self._alipay_user_id = None
  8. self._contract_content = None
  9. self._end_time = None
  10. self._page_url = None
  11. self._start_time = None
  12. self._subscribe = None
  13. @property
  14. def alipay_user_id(self):
  15. return self._alipay_user_id
  16. @alipay_user_id.setter
  17. def alipay_user_id(self, value):
  18. self._alipay_user_id = value
  19. @property
  20. def contract_content(self):
  21. return self._contract_content
  22. @contract_content.setter
  23. def contract_content(self, value):
  24. self._contract_content = value
  25. @property
  26. def end_time(self):
  27. return self._end_time
  28. @end_time.setter
  29. def end_time(self, value):
  30. self._end_time = value
  31. @property
  32. def page_url(self):
  33. return self._page_url
  34. @page_url.setter
  35. def page_url(self, value):
  36. self._page_url = value
  37. @property
  38. def start_time(self):
  39. return self._start_time
  40. @start_time.setter
  41. def start_time(self, value):
  42. self._start_time = value
  43. @property
  44. def subscribe(self):
  45. return self._subscribe
  46. @subscribe.setter
  47. def subscribe(self, value):
  48. self._subscribe = value
  49. def to_alipay_dict(self):
  50. params = dict()
  51. if self.alipay_user_id:
  52. if hasattr(self.alipay_user_id, 'to_alipay_dict'):
  53. params['alipay_user_id'] = self.alipay_user_id.to_alipay_dict()
  54. else:
  55. params['alipay_user_id'] = self.alipay_user_id
  56. if self.contract_content:
  57. if hasattr(self.contract_content, 'to_alipay_dict'):
  58. params['contract_content'] = self.contract_content.to_alipay_dict()
  59. else:
  60. params['contract_content'] = self.contract_content
  61. if self.end_time:
  62. if hasattr(self.end_time, 'to_alipay_dict'):
  63. params['end_time'] = self.end_time.to_alipay_dict()
  64. else:
  65. params['end_time'] = self.end_time
  66. if self.page_url:
  67. if hasattr(self.page_url, 'to_alipay_dict'):
  68. params['page_url'] = self.page_url.to_alipay_dict()
  69. else:
  70. params['page_url'] = self.page_url
  71. if self.start_time:
  72. if hasattr(self.start_time, 'to_alipay_dict'):
  73. params['start_time'] = self.start_time.to_alipay_dict()
  74. else:
  75. params['start_time'] = self.start_time
  76. if self.subscribe:
  77. if hasattr(self.subscribe, 'to_alipay_dict'):
  78. params['subscribe'] = self.subscribe.to_alipay_dict()
  79. else:
  80. params['subscribe'] = self.subscribe
  81. return params
  82. @staticmethod
  83. def from_alipay_dict(d):
  84. if not d:
  85. return None
  86. o = AlipayContract()
  87. if 'alipay_user_id' in d:
  88. o.alipay_user_id = d['alipay_user_id']
  89. if 'contract_content' in d:
  90. o.contract_content = d['contract_content']
  91. if 'end_time' in d:
  92. o.end_time = d['end_time']
  93. if 'page_url' in d:
  94. o.page_url = d['page_url']
  95. if 'start_time' in d:
  96. o.start_time = d['start_time']
  97. if 'subscribe' in d:
  98. o.subscribe = d['subscribe']
  99. return o