IntelligentPromoDetail.py 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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.BudgetInfo import BudgetInfo
  6. from alipay.aop.api.domain.ConstraintInfo import ConstraintInfo
  7. from alipay.aop.api.domain.CrowdConstraintInfo import CrowdConstraintInfo
  8. from alipay.aop.api.domain.IntelligentPromoEffect import IntelligentPromoEffect
  9. from alipay.aop.api.domain.PromoTool import PromoTool
  10. from alipay.aop.api.domain.PublishChannel import PublishChannel
  11. class IntelligentPromoDetail(object):
  12. def __init__(self):
  13. self._budget = None
  14. self._camp_id = None
  15. self._constraint = None
  16. self._crowd_constraint = None
  17. self._desc = None
  18. self._ext_info = None
  19. self._forecast_effect = None
  20. self._merchant_promo_type = None
  21. self._name = None
  22. self._promo_tools = None
  23. self._publish_channels = None
  24. self._template_id = None
  25. @property
  26. def budget(self):
  27. return self._budget
  28. @budget.setter
  29. def budget(self, value):
  30. if isinstance(value, BudgetInfo):
  31. self._budget = value
  32. else:
  33. self._budget = BudgetInfo.from_alipay_dict(value)
  34. @property
  35. def camp_id(self):
  36. return self._camp_id
  37. @camp_id.setter
  38. def camp_id(self, value):
  39. self._camp_id = value
  40. @property
  41. def constraint(self):
  42. return self._constraint
  43. @constraint.setter
  44. def constraint(self, value):
  45. if isinstance(value, ConstraintInfo):
  46. self._constraint = value
  47. else:
  48. self._constraint = ConstraintInfo.from_alipay_dict(value)
  49. @property
  50. def crowd_constraint(self):
  51. return self._crowd_constraint
  52. @crowd_constraint.setter
  53. def crowd_constraint(self, value):
  54. if isinstance(value, CrowdConstraintInfo):
  55. self._crowd_constraint = value
  56. else:
  57. self._crowd_constraint = CrowdConstraintInfo.from_alipay_dict(value)
  58. @property
  59. def desc(self):
  60. return self._desc
  61. @desc.setter
  62. def desc(self, value):
  63. self._desc = value
  64. @property
  65. def ext_info(self):
  66. return self._ext_info
  67. @ext_info.setter
  68. def ext_info(self, value):
  69. self._ext_info = value
  70. @property
  71. def forecast_effect(self):
  72. return self._forecast_effect
  73. @forecast_effect.setter
  74. def forecast_effect(self, value):
  75. if isinstance(value, IntelligentPromoEffect):
  76. self._forecast_effect = value
  77. else:
  78. self._forecast_effect = IntelligentPromoEffect.from_alipay_dict(value)
  79. @property
  80. def merchant_promo_type(self):
  81. return self._merchant_promo_type
  82. @merchant_promo_type.setter
  83. def merchant_promo_type(self, value):
  84. self._merchant_promo_type = value
  85. @property
  86. def name(self):
  87. return self._name
  88. @name.setter
  89. def name(self, value):
  90. self._name = value
  91. @property
  92. def promo_tools(self):
  93. return self._promo_tools
  94. @promo_tools.setter
  95. def promo_tools(self, value):
  96. if isinstance(value, list):
  97. self._promo_tools = list()
  98. for i in value:
  99. if isinstance(i, PromoTool):
  100. self._promo_tools.append(i)
  101. else:
  102. self._promo_tools.append(PromoTool.from_alipay_dict(i))
  103. @property
  104. def publish_channels(self):
  105. return self._publish_channels
  106. @publish_channels.setter
  107. def publish_channels(self, value):
  108. if isinstance(value, list):
  109. self._publish_channels = list()
  110. for i in value:
  111. if isinstance(i, PublishChannel):
  112. self._publish_channels.append(i)
  113. else:
  114. self._publish_channels.append(PublishChannel.from_alipay_dict(i))
  115. @property
  116. def template_id(self):
  117. return self._template_id
  118. @template_id.setter
  119. def template_id(self, value):
  120. self._template_id = value
  121. def to_alipay_dict(self):
  122. params = dict()
  123. if self.budget:
  124. if hasattr(self.budget, 'to_alipay_dict'):
  125. params['budget'] = self.budget.to_alipay_dict()
  126. else:
  127. params['budget'] = self.budget
  128. if self.camp_id:
  129. if hasattr(self.camp_id, 'to_alipay_dict'):
  130. params['camp_id'] = self.camp_id.to_alipay_dict()
  131. else:
  132. params['camp_id'] = self.camp_id
  133. if self.constraint:
  134. if hasattr(self.constraint, 'to_alipay_dict'):
  135. params['constraint'] = self.constraint.to_alipay_dict()
  136. else:
  137. params['constraint'] = self.constraint
  138. if self.crowd_constraint:
  139. if hasattr(self.crowd_constraint, 'to_alipay_dict'):
  140. params['crowd_constraint'] = self.crowd_constraint.to_alipay_dict()
  141. else:
  142. params['crowd_constraint'] = self.crowd_constraint
  143. if self.desc:
  144. if hasattr(self.desc, 'to_alipay_dict'):
  145. params['desc'] = self.desc.to_alipay_dict()
  146. else:
  147. params['desc'] = self.desc
  148. if self.ext_info:
  149. if hasattr(self.ext_info, 'to_alipay_dict'):
  150. params['ext_info'] = self.ext_info.to_alipay_dict()
  151. else:
  152. params['ext_info'] = self.ext_info
  153. if self.forecast_effect:
  154. if hasattr(self.forecast_effect, 'to_alipay_dict'):
  155. params['forecast_effect'] = self.forecast_effect.to_alipay_dict()
  156. else:
  157. params['forecast_effect'] = self.forecast_effect
  158. if self.merchant_promo_type:
  159. if hasattr(self.merchant_promo_type, 'to_alipay_dict'):
  160. params['merchant_promo_type'] = self.merchant_promo_type.to_alipay_dict()
  161. else:
  162. params['merchant_promo_type'] = self.merchant_promo_type
  163. if self.name:
  164. if hasattr(self.name, 'to_alipay_dict'):
  165. params['name'] = self.name.to_alipay_dict()
  166. else:
  167. params['name'] = self.name
  168. if self.promo_tools:
  169. if isinstance(self.promo_tools, list):
  170. for i in range(0, len(self.promo_tools)):
  171. element = self.promo_tools[i]
  172. if hasattr(element, 'to_alipay_dict'):
  173. self.promo_tools[i] = element.to_alipay_dict()
  174. if hasattr(self.promo_tools, 'to_alipay_dict'):
  175. params['promo_tools'] = self.promo_tools.to_alipay_dict()
  176. else:
  177. params['promo_tools'] = self.promo_tools
  178. if self.publish_channels:
  179. if isinstance(self.publish_channels, list):
  180. for i in range(0, len(self.publish_channels)):
  181. element = self.publish_channels[i]
  182. if hasattr(element, 'to_alipay_dict'):
  183. self.publish_channels[i] = element.to_alipay_dict()
  184. if hasattr(self.publish_channels, 'to_alipay_dict'):
  185. params['publish_channels'] = self.publish_channels.to_alipay_dict()
  186. else:
  187. params['publish_channels'] = self.publish_channels
  188. if self.template_id:
  189. if hasattr(self.template_id, 'to_alipay_dict'):
  190. params['template_id'] = self.template_id.to_alipay_dict()
  191. else:
  192. params['template_id'] = self.template_id
  193. return params
  194. @staticmethod
  195. def from_alipay_dict(d):
  196. if not d:
  197. return None
  198. o = IntelligentPromoDetail()
  199. if 'budget' in d:
  200. o.budget = d['budget']
  201. if 'camp_id' in d:
  202. o.camp_id = d['camp_id']
  203. if 'constraint' in d:
  204. o.constraint = d['constraint']
  205. if 'crowd_constraint' in d:
  206. o.crowd_constraint = d['crowd_constraint']
  207. if 'desc' in d:
  208. o.desc = d['desc']
  209. if 'ext_info' in d:
  210. o.ext_info = d['ext_info']
  211. if 'forecast_effect' in d:
  212. o.forecast_effect = d['forecast_effect']
  213. if 'merchant_promo_type' in d:
  214. o.merchant_promo_type = d['merchant_promo_type']
  215. if 'name' in d:
  216. o.name = d['name']
  217. if 'promo_tools' in d:
  218. o.promo_tools = d['promo_tools']
  219. if 'publish_channels' in d:
  220. o.publish_channels = d['publish_channels']
  221. if 'template_id' in d:
  222. o.template_id = d['template_id']
  223. return o