IcrowdUseParam.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.IcrowdUseContext import IcrowdUseContext
  6. class IcrowdUseParam(object):
  7. def __init__(self):
  8. self._context = None
  9. self._external_info = None
  10. self._method_id = None
  11. @property
  12. def context(self):
  13. return self._context
  14. @context.setter
  15. def context(self, value):
  16. if isinstance(value, IcrowdUseContext):
  17. self._context = value
  18. else:
  19. self._context = IcrowdUseContext.from_alipay_dict(value)
  20. @property
  21. def external_info(self):
  22. return self._external_info
  23. @external_info.setter
  24. def external_info(self, value):
  25. if isinstance(value, list):
  26. self._external_info = list()
  27. for i in value:
  28. self._external_info.append(i)
  29. @property
  30. def method_id(self):
  31. return self._method_id
  32. @method_id.setter
  33. def method_id(self, value):
  34. self._method_id = value
  35. def to_alipay_dict(self):
  36. params = dict()
  37. if self.context:
  38. if hasattr(self.context, 'to_alipay_dict'):
  39. params['context'] = self.context.to_alipay_dict()
  40. else:
  41. params['context'] = self.context
  42. if self.external_info:
  43. if isinstance(self.external_info, list):
  44. for i in range(0, len(self.external_info)):
  45. element = self.external_info[i]
  46. if hasattr(element, 'to_alipay_dict'):
  47. self.external_info[i] = element.to_alipay_dict()
  48. if hasattr(self.external_info, 'to_alipay_dict'):
  49. params['external_info'] = self.external_info.to_alipay_dict()
  50. else:
  51. params['external_info'] = self.external_info
  52. if self.method_id:
  53. if hasattr(self.method_id, 'to_alipay_dict'):
  54. params['method_id'] = self.method_id.to_alipay_dict()
  55. else:
  56. params['method_id'] = self.method_id
  57. return params
  58. @staticmethod
  59. def from_alipay_dict(d):
  60. if not d:
  61. return None
  62. o = IcrowdUseParam()
  63. if 'context' in d:
  64. o.context = d['context']
  65. if 'external_info' in d:
  66. o.external_info = d['external_info']
  67. if 'method_id' in d:
  68. o.method_id = d['method_id']
  69. return o