SignField.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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.Signer import Signer
  6. class SignField(object):
  7. def __init__(self):
  8. self._auto_execute = None
  9. self._signer = None
  10. self._struct_key = None
  11. @property
  12. def auto_execute(self):
  13. return self._auto_execute
  14. @auto_execute.setter
  15. def auto_execute(self, value):
  16. self._auto_execute = value
  17. @property
  18. def signer(self):
  19. return self._signer
  20. @signer.setter
  21. def signer(self, value):
  22. if isinstance(value, Signer):
  23. self._signer = value
  24. else:
  25. self._signer = Signer.from_alipay_dict(value)
  26. @property
  27. def struct_key(self):
  28. return self._struct_key
  29. @struct_key.setter
  30. def struct_key(self, value):
  31. self._struct_key = value
  32. def to_alipay_dict(self):
  33. params = dict()
  34. if self.auto_execute:
  35. if hasattr(self.auto_execute, 'to_alipay_dict'):
  36. params['auto_execute'] = self.auto_execute.to_alipay_dict()
  37. else:
  38. params['auto_execute'] = self.auto_execute
  39. if self.signer:
  40. if hasattr(self.signer, 'to_alipay_dict'):
  41. params['signer'] = self.signer.to_alipay_dict()
  42. else:
  43. params['signer'] = self.signer
  44. if self.struct_key:
  45. if hasattr(self.struct_key, 'to_alipay_dict'):
  46. params['struct_key'] = self.struct_key.to_alipay_dict()
  47. else:
  48. params['struct_key'] = self.struct_key
  49. return params
  50. @staticmethod
  51. def from_alipay_dict(d):
  52. if not d:
  53. return None
  54. o = SignField()
  55. if 'auto_execute' in d:
  56. o.auto_execute = d['auto_execute']
  57. if 'signer' in d:
  58. o.signer = d['signer']
  59. if 'struct_key' in d:
  60. o.struct_key = d['struct_key']
  61. return o