KbAdvertSubjectVoucher.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class KbAdvertSubjectVoucher(object):
  6. def __init__(self):
  7. self._brand_name = None
  8. self._city_ids = None
  9. self._merchant_name = None
  10. self._purchase_mode = None
  11. self._voucher_id = None
  12. self._voucher_name = None
  13. self._voucher_type = None
  14. @property
  15. def brand_name(self):
  16. return self._brand_name
  17. @brand_name.setter
  18. def brand_name(self, value):
  19. self._brand_name = value
  20. @property
  21. def city_ids(self):
  22. return self._city_ids
  23. @city_ids.setter
  24. def city_ids(self, value):
  25. if isinstance(value, list):
  26. self._city_ids = list()
  27. for i in value:
  28. self._city_ids.append(i)
  29. @property
  30. def merchant_name(self):
  31. return self._merchant_name
  32. @merchant_name.setter
  33. def merchant_name(self, value):
  34. self._merchant_name = value
  35. @property
  36. def purchase_mode(self):
  37. return self._purchase_mode
  38. @purchase_mode.setter
  39. def purchase_mode(self, value):
  40. self._purchase_mode = value
  41. @property
  42. def voucher_id(self):
  43. return self._voucher_id
  44. @voucher_id.setter
  45. def voucher_id(self, value):
  46. self._voucher_id = value
  47. @property
  48. def voucher_name(self):
  49. return self._voucher_name
  50. @voucher_name.setter
  51. def voucher_name(self, value):
  52. self._voucher_name = value
  53. @property
  54. def voucher_type(self):
  55. return self._voucher_type
  56. @voucher_type.setter
  57. def voucher_type(self, value):
  58. self._voucher_type = value
  59. def to_alipay_dict(self):
  60. params = dict()
  61. if self.brand_name:
  62. if hasattr(self.brand_name, 'to_alipay_dict'):
  63. params['brand_name'] = self.brand_name.to_alipay_dict()
  64. else:
  65. params['brand_name'] = self.brand_name
  66. if self.city_ids:
  67. if isinstance(self.city_ids, list):
  68. for i in range(0, len(self.city_ids)):
  69. element = self.city_ids[i]
  70. if hasattr(element, 'to_alipay_dict'):
  71. self.city_ids[i] = element.to_alipay_dict()
  72. if hasattr(self.city_ids, 'to_alipay_dict'):
  73. params['city_ids'] = self.city_ids.to_alipay_dict()
  74. else:
  75. params['city_ids'] = self.city_ids
  76. if self.merchant_name:
  77. if hasattr(self.merchant_name, 'to_alipay_dict'):
  78. params['merchant_name'] = self.merchant_name.to_alipay_dict()
  79. else:
  80. params['merchant_name'] = self.merchant_name
  81. if self.purchase_mode:
  82. if hasattr(self.purchase_mode, 'to_alipay_dict'):
  83. params['purchase_mode'] = self.purchase_mode.to_alipay_dict()
  84. else:
  85. params['purchase_mode'] = self.purchase_mode
  86. if self.voucher_id:
  87. if hasattr(self.voucher_id, 'to_alipay_dict'):
  88. params['voucher_id'] = self.voucher_id.to_alipay_dict()
  89. else:
  90. params['voucher_id'] = self.voucher_id
  91. if self.voucher_name:
  92. if hasattr(self.voucher_name, 'to_alipay_dict'):
  93. params['voucher_name'] = self.voucher_name.to_alipay_dict()
  94. else:
  95. params['voucher_name'] = self.voucher_name
  96. if self.voucher_type:
  97. if hasattr(self.voucher_type, 'to_alipay_dict'):
  98. params['voucher_type'] = self.voucher_type.to_alipay_dict()
  99. else:
  100. params['voucher_type'] = self.voucher_type
  101. return params
  102. @staticmethod
  103. def from_alipay_dict(d):
  104. if not d:
  105. return None
  106. o = KbAdvertSubjectVoucher()
  107. if 'brand_name' in d:
  108. o.brand_name = d['brand_name']
  109. if 'city_ids' in d:
  110. o.city_ids = d['city_ids']
  111. if 'merchant_name' in d:
  112. o.merchant_name = d['merchant_name']
  113. if 'purchase_mode' in d:
  114. o.purchase_mode = d['purchase_mode']
  115. if 'voucher_id' in d:
  116. o.voucher_id = d['voucher_id']
  117. if 'voucher_name' in d:
  118. o.voucher_name = d['voucher_name']
  119. if 'voucher_type' in d:
  120. o.voucher_type = d['voucher_type']
  121. return o