FileSignature.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.SealPosition import SealPosition
  6. class FileSignature(object):
  7. def __init__(self):
  8. self._cert_no = None
  9. self._seal_id = None
  10. self._seal_position = None
  11. self._seal_type = None
  12. self._sign_reason = None
  13. self._signature_type = None
  14. @property
  15. def cert_no(self):
  16. return self._cert_no
  17. @cert_no.setter
  18. def cert_no(self, value):
  19. self._cert_no = value
  20. @property
  21. def seal_id(self):
  22. return self._seal_id
  23. @seal_id.setter
  24. def seal_id(self, value):
  25. self._seal_id = value
  26. @property
  27. def seal_position(self):
  28. return self._seal_position
  29. @seal_position.setter
  30. def seal_position(self, value):
  31. if isinstance(value, SealPosition):
  32. self._seal_position = value
  33. else:
  34. self._seal_position = SealPosition.from_alipay_dict(value)
  35. @property
  36. def seal_type(self):
  37. return self._seal_type
  38. @seal_type.setter
  39. def seal_type(self, value):
  40. self._seal_type = value
  41. @property
  42. def sign_reason(self):
  43. return self._sign_reason
  44. @sign_reason.setter
  45. def sign_reason(self, value):
  46. self._sign_reason = value
  47. @property
  48. def signature_type(self):
  49. return self._signature_type
  50. @signature_type.setter
  51. def signature_type(self, value):
  52. self._signature_type = value
  53. def to_alipay_dict(self):
  54. params = dict()
  55. if self.cert_no:
  56. if hasattr(self.cert_no, 'to_alipay_dict'):
  57. params['cert_no'] = self.cert_no.to_alipay_dict()
  58. else:
  59. params['cert_no'] = self.cert_no
  60. if self.seal_id:
  61. if hasattr(self.seal_id, 'to_alipay_dict'):
  62. params['seal_id'] = self.seal_id.to_alipay_dict()
  63. else:
  64. params['seal_id'] = self.seal_id
  65. if self.seal_position:
  66. if hasattr(self.seal_position, 'to_alipay_dict'):
  67. params['seal_position'] = self.seal_position.to_alipay_dict()
  68. else:
  69. params['seal_position'] = self.seal_position
  70. if self.seal_type:
  71. if hasattr(self.seal_type, 'to_alipay_dict'):
  72. params['seal_type'] = self.seal_type.to_alipay_dict()
  73. else:
  74. params['seal_type'] = self.seal_type
  75. if self.sign_reason:
  76. if hasattr(self.sign_reason, 'to_alipay_dict'):
  77. params['sign_reason'] = self.sign_reason.to_alipay_dict()
  78. else:
  79. params['sign_reason'] = self.sign_reason
  80. if self.signature_type:
  81. if hasattr(self.signature_type, 'to_alipay_dict'):
  82. params['signature_type'] = self.signature_type.to_alipay_dict()
  83. else:
  84. params['signature_type'] = self.signature_type
  85. return params
  86. @staticmethod
  87. def from_alipay_dict(d):
  88. if not d:
  89. return None
  90. o = FileSignature()
  91. if 'cert_no' in d:
  92. o.cert_no = d['cert_no']
  93. if 'seal_id' in d:
  94. o.seal_id = d['seal_id']
  95. if 'seal_position' in d:
  96. o.seal_position = d['seal_position']
  97. if 'seal_type' in d:
  98. o.seal_type = d['seal_type']
  99. if 'sign_reason' in d:
  100. o.sign_reason = d['sign_reason']
  101. if 'signature_type' in d:
  102. o.signature_type = d['signature_type']
  103. return o