AlipayCommerceTradeApplyModel.py 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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.TradeApplyParams import TradeApplyParams
  6. class AlipayCommerceTradeApplyModel(object):
  7. def __init__(self):
  8. self._amount_detail = None
  9. self._channel = None
  10. self._interface_version = None
  11. self._op_code = None
  12. self._order_detail = None
  13. self._scene_code = None
  14. self._target_id = None
  15. self._target_id_type = None
  16. self._trade_apply_params = None
  17. @property
  18. def amount_detail(self):
  19. return self._amount_detail
  20. @amount_detail.setter
  21. def amount_detail(self, value):
  22. self._amount_detail = value
  23. @property
  24. def channel(self):
  25. return self._channel
  26. @channel.setter
  27. def channel(self, value):
  28. self._channel = value
  29. @property
  30. def interface_version(self):
  31. return self._interface_version
  32. @interface_version.setter
  33. def interface_version(self, value):
  34. self._interface_version = value
  35. @property
  36. def op_code(self):
  37. return self._op_code
  38. @op_code.setter
  39. def op_code(self, value):
  40. self._op_code = value
  41. @property
  42. def order_detail(self):
  43. return self._order_detail
  44. @order_detail.setter
  45. def order_detail(self, value):
  46. self._order_detail = value
  47. @property
  48. def scene_code(self):
  49. return self._scene_code
  50. @scene_code.setter
  51. def scene_code(self, value):
  52. self._scene_code = value
  53. @property
  54. def target_id(self):
  55. return self._target_id
  56. @target_id.setter
  57. def target_id(self, value):
  58. self._target_id = value
  59. @property
  60. def target_id_type(self):
  61. return self._target_id_type
  62. @target_id_type.setter
  63. def target_id_type(self, value):
  64. self._target_id_type = value
  65. @property
  66. def trade_apply_params(self):
  67. return self._trade_apply_params
  68. @trade_apply_params.setter
  69. def trade_apply_params(self, value):
  70. if isinstance(value, TradeApplyParams):
  71. self._trade_apply_params = value
  72. else:
  73. self._trade_apply_params = TradeApplyParams.from_alipay_dict(value)
  74. def to_alipay_dict(self):
  75. params = dict()
  76. if self.amount_detail:
  77. if hasattr(self.amount_detail, 'to_alipay_dict'):
  78. params['amount_detail'] = self.amount_detail.to_alipay_dict()
  79. else:
  80. params['amount_detail'] = self.amount_detail
  81. if self.channel:
  82. if hasattr(self.channel, 'to_alipay_dict'):
  83. params['channel'] = self.channel.to_alipay_dict()
  84. else:
  85. params['channel'] = self.channel
  86. if self.interface_version:
  87. if hasattr(self.interface_version, 'to_alipay_dict'):
  88. params['interface_version'] = self.interface_version.to_alipay_dict()
  89. else:
  90. params['interface_version'] = self.interface_version
  91. if self.op_code:
  92. if hasattr(self.op_code, 'to_alipay_dict'):
  93. params['op_code'] = self.op_code.to_alipay_dict()
  94. else:
  95. params['op_code'] = self.op_code
  96. if self.order_detail:
  97. if hasattr(self.order_detail, 'to_alipay_dict'):
  98. params['order_detail'] = self.order_detail.to_alipay_dict()
  99. else:
  100. params['order_detail'] = self.order_detail
  101. if self.scene_code:
  102. if hasattr(self.scene_code, 'to_alipay_dict'):
  103. params['scene_code'] = self.scene_code.to_alipay_dict()
  104. else:
  105. params['scene_code'] = self.scene_code
  106. if self.target_id:
  107. if hasattr(self.target_id, 'to_alipay_dict'):
  108. params['target_id'] = self.target_id.to_alipay_dict()
  109. else:
  110. params['target_id'] = self.target_id
  111. if self.target_id_type:
  112. if hasattr(self.target_id_type, 'to_alipay_dict'):
  113. params['target_id_type'] = self.target_id_type.to_alipay_dict()
  114. else:
  115. params['target_id_type'] = self.target_id_type
  116. if self.trade_apply_params:
  117. if hasattr(self.trade_apply_params, 'to_alipay_dict'):
  118. params['trade_apply_params'] = self.trade_apply_params.to_alipay_dict()
  119. else:
  120. params['trade_apply_params'] = self.trade_apply_params
  121. return params
  122. @staticmethod
  123. def from_alipay_dict(d):
  124. if not d:
  125. return None
  126. o = AlipayCommerceTradeApplyModel()
  127. if 'amount_detail' in d:
  128. o.amount_detail = d['amount_detail']
  129. if 'channel' in d:
  130. o.channel = d['channel']
  131. if 'interface_version' in d:
  132. o.interface_version = d['interface_version']
  133. if 'op_code' in d:
  134. o.op_code = d['op_code']
  135. if 'order_detail' in d:
  136. o.order_detail = d['order_detail']
  137. if 'scene_code' in d:
  138. o.scene_code = d['scene_code']
  139. if 'target_id' in d:
  140. o.target_id = d['target_id']
  141. if 'target_id_type' in d:
  142. o.target_id_type = d['target_id_type']
  143. if 'trade_apply_params' in d:
  144. o.trade_apply_params = d['trade_apply_params']
  145. return o