AlipayOpenPublicPersonalizedMenuCreateModel.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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.ButtonObject import ButtonObject
  6. from alipay.aop.api.domain.LabelRule import LabelRule
  7. class AlipayOpenPublicPersonalizedMenuCreateModel(object):
  8. def __init__(self):
  9. self._button = None
  10. self._label_rule = None
  11. self._type = None
  12. @property
  13. def button(self):
  14. return self._button
  15. @button.setter
  16. def button(self, value):
  17. if isinstance(value, list):
  18. self._button = list()
  19. for i in value:
  20. if isinstance(i, ButtonObject):
  21. self._button.append(i)
  22. else:
  23. self._button.append(ButtonObject.from_alipay_dict(i))
  24. @property
  25. def label_rule(self):
  26. return self._label_rule
  27. @label_rule.setter
  28. def label_rule(self, value):
  29. if isinstance(value, list):
  30. self._label_rule = list()
  31. for i in value:
  32. if isinstance(i, LabelRule):
  33. self._label_rule.append(i)
  34. else:
  35. self._label_rule.append(LabelRule.from_alipay_dict(i))
  36. @property
  37. def type(self):
  38. return self._type
  39. @type.setter
  40. def type(self, value):
  41. self._type = value
  42. def to_alipay_dict(self):
  43. params = dict()
  44. if self.button:
  45. if isinstance(self.button, list):
  46. for i in range(0, len(self.button)):
  47. element = self.button[i]
  48. if hasattr(element, 'to_alipay_dict'):
  49. self.button[i] = element.to_alipay_dict()
  50. if hasattr(self.button, 'to_alipay_dict'):
  51. params['button'] = self.button.to_alipay_dict()
  52. else:
  53. params['button'] = self.button
  54. if self.label_rule:
  55. if isinstance(self.label_rule, list):
  56. for i in range(0, len(self.label_rule)):
  57. element = self.label_rule[i]
  58. if hasattr(element, 'to_alipay_dict'):
  59. self.label_rule[i] = element.to_alipay_dict()
  60. if hasattr(self.label_rule, 'to_alipay_dict'):
  61. params['label_rule'] = self.label_rule.to_alipay_dict()
  62. else:
  63. params['label_rule'] = self.label_rule
  64. if self.type:
  65. if hasattr(self.type, 'to_alipay_dict'):
  66. params['type'] = self.type.to_alipay_dict()
  67. else:
  68. params['type'] = self.type
  69. return params
  70. @staticmethod
  71. def from_alipay_dict(d):
  72. if not d:
  73. return None
  74. o = AlipayOpenPublicPersonalizedMenuCreateModel()
  75. if 'button' in d:
  76. o.button = d['button']
  77. if 'label_rule' in d:
  78. o.label_rule = d['label_rule']
  79. if 'type' in d:
  80. o.type = d['type']
  81. return o