ConditionItemPattern.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class ConditionItemPattern(object):
  6. def __init__(self):
  7. self._logical_operator = None
  8. self._operation_value = None
  9. self._operator_rule = None
  10. self._period = None
  11. self._rule_unit = None
  12. @property
  13. def logical_operator(self):
  14. return self._logical_operator
  15. @logical_operator.setter
  16. def logical_operator(self, value):
  17. self._logical_operator = value
  18. @property
  19. def operation_value(self):
  20. return self._operation_value
  21. @operation_value.setter
  22. def operation_value(self, value):
  23. self._operation_value = value
  24. @property
  25. def operator_rule(self):
  26. return self._operator_rule
  27. @operator_rule.setter
  28. def operator_rule(self, value):
  29. self._operator_rule = value
  30. @property
  31. def period(self):
  32. return self._period
  33. @period.setter
  34. def period(self, value):
  35. self._period = value
  36. @property
  37. def rule_unit(self):
  38. return self._rule_unit
  39. @rule_unit.setter
  40. def rule_unit(self, value):
  41. self._rule_unit = value
  42. def to_alipay_dict(self):
  43. params = dict()
  44. if self.logical_operator:
  45. if hasattr(self.logical_operator, 'to_alipay_dict'):
  46. params['logical_operator'] = self.logical_operator.to_alipay_dict()
  47. else:
  48. params['logical_operator'] = self.logical_operator
  49. if self.operation_value:
  50. if hasattr(self.operation_value, 'to_alipay_dict'):
  51. params['operation_value'] = self.operation_value.to_alipay_dict()
  52. else:
  53. params['operation_value'] = self.operation_value
  54. if self.operator_rule:
  55. if hasattr(self.operator_rule, 'to_alipay_dict'):
  56. params['operator_rule'] = self.operator_rule.to_alipay_dict()
  57. else:
  58. params['operator_rule'] = self.operator_rule
  59. if self.period:
  60. if hasattr(self.period, 'to_alipay_dict'):
  61. params['period'] = self.period.to_alipay_dict()
  62. else:
  63. params['period'] = self.period
  64. if self.rule_unit:
  65. if hasattr(self.rule_unit, 'to_alipay_dict'):
  66. params['rule_unit'] = self.rule_unit.to_alipay_dict()
  67. else:
  68. params['rule_unit'] = self.rule_unit
  69. return params
  70. @staticmethod
  71. def from_alipay_dict(d):
  72. if not d:
  73. return None
  74. o = ConditionItemPattern()
  75. if 'logical_operator' in d:
  76. o.logical_operator = d['logical_operator']
  77. if 'operation_value' in d:
  78. o.operation_value = d['operation_value']
  79. if 'operator_rule' in d:
  80. o.operator_rule = d['operator_rule']
  81. if 'period' in d:
  82. o.period = d['period']
  83. if 'rule_unit' in d:
  84. o.rule_unit = d['rule_unit']
  85. return o