SendRule.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class SendRule(object):
  6. def __init__(self):
  7. self._allow_repeat_send = None
  8. self._min_cost = None
  9. self._send_budget = None
  10. self._send_num = None
  11. @property
  12. def allow_repeat_send(self):
  13. return self._allow_repeat_send
  14. @allow_repeat_send.setter
  15. def allow_repeat_send(self, value):
  16. self._allow_repeat_send = value
  17. @property
  18. def min_cost(self):
  19. return self._min_cost
  20. @min_cost.setter
  21. def min_cost(self, value):
  22. self._min_cost = value
  23. @property
  24. def send_budget(self):
  25. return self._send_budget
  26. @send_budget.setter
  27. def send_budget(self, value):
  28. self._send_budget = value
  29. @property
  30. def send_num(self):
  31. return self._send_num
  32. @send_num.setter
  33. def send_num(self, value):
  34. self._send_num = value
  35. def to_alipay_dict(self):
  36. params = dict()
  37. if self.allow_repeat_send:
  38. if hasattr(self.allow_repeat_send, 'to_alipay_dict'):
  39. params['allow_repeat_send'] = self.allow_repeat_send.to_alipay_dict()
  40. else:
  41. params['allow_repeat_send'] = self.allow_repeat_send
  42. if self.min_cost:
  43. if hasattr(self.min_cost, 'to_alipay_dict'):
  44. params['min_cost'] = self.min_cost.to_alipay_dict()
  45. else:
  46. params['min_cost'] = self.min_cost
  47. if self.send_budget:
  48. if hasattr(self.send_budget, 'to_alipay_dict'):
  49. params['send_budget'] = self.send_budget.to_alipay_dict()
  50. else:
  51. params['send_budget'] = self.send_budget
  52. if self.send_num:
  53. if hasattr(self.send_num, 'to_alipay_dict'):
  54. params['send_num'] = self.send_num.to_alipay_dict()
  55. else:
  56. params['send_num'] = self.send_num
  57. return params
  58. @staticmethod
  59. def from_alipay_dict(d):
  60. if not d:
  61. return None
  62. o = SendRule()
  63. if 'allow_repeat_send' in d:
  64. o.allow_repeat_send = d['allow_repeat_send']
  65. if 'min_cost' in d:
  66. o.min_cost = d['min_cost']
  67. if 'send_budget' in d:
  68. o.send_budget = d['send_budget']
  69. if 'send_num' in d:
  70. o.send_num = d['send_num']
  71. return o