AssetParams.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class AssetParams(object):
  6. def __init__(self):
  7. self._asset_type = None
  8. self._card_no = None
  9. self._inst_id = None
  10. @property
  11. def asset_type(self):
  12. return self._asset_type
  13. @asset_type.setter
  14. def asset_type(self, value):
  15. self._asset_type = value
  16. @property
  17. def card_no(self):
  18. return self._card_no
  19. @card_no.setter
  20. def card_no(self, value):
  21. self._card_no = value
  22. @property
  23. def inst_id(self):
  24. return self._inst_id
  25. @inst_id.setter
  26. def inst_id(self, value):
  27. self._inst_id = value
  28. def to_alipay_dict(self):
  29. params = dict()
  30. if self.asset_type:
  31. if hasattr(self.asset_type, 'to_alipay_dict'):
  32. params['asset_type'] = self.asset_type.to_alipay_dict()
  33. else:
  34. params['asset_type'] = self.asset_type
  35. if self.card_no:
  36. if hasattr(self.card_no, 'to_alipay_dict'):
  37. params['card_no'] = self.card_no.to_alipay_dict()
  38. else:
  39. params['card_no'] = self.card_no
  40. if self.inst_id:
  41. if hasattr(self.inst_id, 'to_alipay_dict'):
  42. params['inst_id'] = self.inst_id.to_alipay_dict()
  43. else:
  44. params['inst_id'] = self.inst_id
  45. return params
  46. @staticmethod
  47. def from_alipay_dict(d):
  48. if not d:
  49. return None
  50. o = AssetParams()
  51. if 'asset_type' in d:
  52. o.asset_type = d['asset_type']
  53. if 'card_no' in d:
  54. o.card_no = d['card_no']
  55. if 'inst_id' in d:
  56. o.inst_id = d['inst_id']
  57. return o