SupportFunction.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class SupportFunction(object):
  6. def __init__(self):
  7. self._card_name = None
  8. self._card_type = None
  9. self._function_type = None
  10. self._goto_url = None
  11. @property
  12. def card_name(self):
  13. return self._card_name
  14. @card_name.setter
  15. def card_name(self, value):
  16. self._card_name = value
  17. @property
  18. def card_type(self):
  19. return self._card_type
  20. @card_type.setter
  21. def card_type(self, value):
  22. self._card_type = value
  23. @property
  24. def function_type(self):
  25. return self._function_type
  26. @function_type.setter
  27. def function_type(self, value):
  28. if isinstance(value, list):
  29. self._function_type = list()
  30. for i in value:
  31. self._function_type.append(i)
  32. @property
  33. def goto_url(self):
  34. return self._goto_url
  35. @goto_url.setter
  36. def goto_url(self, value):
  37. self._goto_url = value
  38. def to_alipay_dict(self):
  39. params = dict()
  40. if self.card_name:
  41. if hasattr(self.card_name, 'to_alipay_dict'):
  42. params['card_name'] = self.card_name.to_alipay_dict()
  43. else:
  44. params['card_name'] = self.card_name
  45. if self.card_type:
  46. if hasattr(self.card_type, 'to_alipay_dict'):
  47. params['card_type'] = self.card_type.to_alipay_dict()
  48. else:
  49. params['card_type'] = self.card_type
  50. if self.function_type:
  51. if isinstance(self.function_type, list):
  52. for i in range(0, len(self.function_type)):
  53. element = self.function_type[i]
  54. if hasattr(element, 'to_alipay_dict'):
  55. self.function_type[i] = element.to_alipay_dict()
  56. if hasattr(self.function_type, 'to_alipay_dict'):
  57. params['function_type'] = self.function_type.to_alipay_dict()
  58. else:
  59. params['function_type'] = self.function_type
  60. if self.goto_url:
  61. if hasattr(self.goto_url, 'to_alipay_dict'):
  62. params['goto_url'] = self.goto_url.to_alipay_dict()
  63. else:
  64. params['goto_url'] = self.goto_url
  65. return params
  66. @staticmethod
  67. def from_alipay_dict(d):
  68. if not d:
  69. return None
  70. o = SupportFunction()
  71. if 'card_name' in d:
  72. o.card_name = d['card_name']
  73. if 'card_type' in d:
  74. o.card_type = d['card_type']
  75. if 'function_type' in d:
  76. o.function_type = d['function_type']
  77. if 'goto_url' in d:
  78. o.goto_url = d['goto_url']
  79. return o