AdPlan.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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.AdGroup import AdGroup
  6. class AdPlan(object):
  7. def __init__(self):
  8. self._ad_user_id = None
  9. self._budget = None
  10. self._end_date = None
  11. self._group_list = None
  12. self._plan_id = None
  13. self._plan_name = None
  14. self._quantity = None
  15. self._start_date = None
  16. @property
  17. def ad_user_id(self):
  18. return self._ad_user_id
  19. @ad_user_id.setter
  20. def ad_user_id(self, value):
  21. self._ad_user_id = value
  22. @property
  23. def budget(self):
  24. return self._budget
  25. @budget.setter
  26. def budget(self, value):
  27. self._budget = value
  28. @property
  29. def end_date(self):
  30. return self._end_date
  31. @end_date.setter
  32. def end_date(self, value):
  33. self._end_date = value
  34. @property
  35. def group_list(self):
  36. return self._group_list
  37. @group_list.setter
  38. def group_list(self, value):
  39. if isinstance(value, AdGroup):
  40. self._group_list = value
  41. else:
  42. self._group_list = AdGroup.from_alipay_dict(value)
  43. @property
  44. def plan_id(self):
  45. return self._plan_id
  46. @plan_id.setter
  47. def plan_id(self, value):
  48. self._plan_id = value
  49. @property
  50. def plan_name(self):
  51. return self._plan_name
  52. @plan_name.setter
  53. def plan_name(self, value):
  54. self._plan_name = value
  55. @property
  56. def quantity(self):
  57. return self._quantity
  58. @quantity.setter
  59. def quantity(self, value):
  60. self._quantity = value
  61. @property
  62. def start_date(self):
  63. return self._start_date
  64. @start_date.setter
  65. def start_date(self, value):
  66. self._start_date = value
  67. def to_alipay_dict(self):
  68. params = dict()
  69. if self.ad_user_id:
  70. if hasattr(self.ad_user_id, 'to_alipay_dict'):
  71. params['ad_user_id'] = self.ad_user_id.to_alipay_dict()
  72. else:
  73. params['ad_user_id'] = self.ad_user_id
  74. if self.budget:
  75. if hasattr(self.budget, 'to_alipay_dict'):
  76. params['budget'] = self.budget.to_alipay_dict()
  77. else:
  78. params['budget'] = self.budget
  79. if self.end_date:
  80. if hasattr(self.end_date, 'to_alipay_dict'):
  81. params['end_date'] = self.end_date.to_alipay_dict()
  82. else:
  83. params['end_date'] = self.end_date
  84. if self.group_list:
  85. if hasattr(self.group_list, 'to_alipay_dict'):
  86. params['group_list'] = self.group_list.to_alipay_dict()
  87. else:
  88. params['group_list'] = self.group_list
  89. if self.plan_id:
  90. if hasattr(self.plan_id, 'to_alipay_dict'):
  91. params['plan_id'] = self.plan_id.to_alipay_dict()
  92. else:
  93. params['plan_id'] = self.plan_id
  94. if self.plan_name:
  95. if hasattr(self.plan_name, 'to_alipay_dict'):
  96. params['plan_name'] = self.plan_name.to_alipay_dict()
  97. else:
  98. params['plan_name'] = self.plan_name
  99. if self.quantity:
  100. if hasattr(self.quantity, 'to_alipay_dict'):
  101. params['quantity'] = self.quantity.to_alipay_dict()
  102. else:
  103. params['quantity'] = self.quantity
  104. if self.start_date:
  105. if hasattr(self.start_date, 'to_alipay_dict'):
  106. params['start_date'] = self.start_date.to_alipay_dict()
  107. else:
  108. params['start_date'] = self.start_date
  109. return params
  110. @staticmethod
  111. def from_alipay_dict(d):
  112. if not d:
  113. return None
  114. o = AdPlan()
  115. if 'ad_user_id' in d:
  116. o.ad_user_id = d['ad_user_id']
  117. if 'budget' in d:
  118. o.budget = d['budget']
  119. if 'end_date' in d:
  120. o.end_date = d['end_date']
  121. if 'group_list' in d:
  122. o.group_list = d['group_list']
  123. if 'plan_id' in d:
  124. o.plan_id = d['plan_id']
  125. if 'plan_name' in d:
  126. o.plan_name = d['plan_name']
  127. if 'quantity' in d:
  128. o.quantity = d['quantity']
  129. if 'start_date' in d:
  130. o.start_date = d['start_date']
  131. return o