AttachmentExplain.py 2.9 KB

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