ContactInfo.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class ContactInfo(object):
  6. def __init__(self):
  7. self._email = None
  8. self._id_card_no = None
  9. self._mobile = None
  10. self._name = None
  11. self._phone = None
  12. self._tag = None
  13. self._type = None
  14. @property
  15. def email(self):
  16. return self._email
  17. @email.setter
  18. def email(self, value):
  19. self._email = value
  20. @property
  21. def id_card_no(self):
  22. return self._id_card_no
  23. @id_card_no.setter
  24. def id_card_no(self, value):
  25. self._id_card_no = value
  26. @property
  27. def mobile(self):
  28. return self._mobile
  29. @mobile.setter
  30. def mobile(self, value):
  31. self._mobile = value
  32. @property
  33. def name(self):
  34. return self._name
  35. @name.setter
  36. def name(self, value):
  37. self._name = value
  38. @property
  39. def phone(self):
  40. return self._phone
  41. @phone.setter
  42. def phone(self, value):
  43. self._phone = value
  44. @property
  45. def tag(self):
  46. return self._tag
  47. @tag.setter
  48. def tag(self, value):
  49. if isinstance(value, list):
  50. self._tag = list()
  51. for i in value:
  52. self._tag.append(i)
  53. @property
  54. def type(self):
  55. return self._type
  56. @type.setter
  57. def type(self, value):
  58. self._type = value
  59. def to_alipay_dict(self):
  60. params = dict()
  61. if self.email:
  62. if hasattr(self.email, 'to_alipay_dict'):
  63. params['email'] = self.email.to_alipay_dict()
  64. else:
  65. params['email'] = self.email
  66. if self.id_card_no:
  67. if hasattr(self.id_card_no, 'to_alipay_dict'):
  68. params['id_card_no'] = self.id_card_no.to_alipay_dict()
  69. else:
  70. params['id_card_no'] = self.id_card_no
  71. if self.mobile:
  72. if hasattr(self.mobile, 'to_alipay_dict'):
  73. params['mobile'] = self.mobile.to_alipay_dict()
  74. else:
  75. params['mobile'] = self.mobile
  76. if self.name:
  77. if hasattr(self.name, 'to_alipay_dict'):
  78. params['name'] = self.name.to_alipay_dict()
  79. else:
  80. params['name'] = self.name
  81. if self.phone:
  82. if hasattr(self.phone, 'to_alipay_dict'):
  83. params['phone'] = self.phone.to_alipay_dict()
  84. else:
  85. params['phone'] = self.phone
  86. if self.tag:
  87. if isinstance(self.tag, list):
  88. for i in range(0, len(self.tag)):
  89. element = self.tag[i]
  90. if hasattr(element, 'to_alipay_dict'):
  91. self.tag[i] = element.to_alipay_dict()
  92. if hasattr(self.tag, 'to_alipay_dict'):
  93. params['tag'] = self.tag.to_alipay_dict()
  94. else:
  95. params['tag'] = self.tag
  96. if self.type:
  97. if hasattr(self.type, 'to_alipay_dict'):
  98. params['type'] = self.type.to_alipay_dict()
  99. else:
  100. params['type'] = self.type
  101. return params
  102. @staticmethod
  103. def from_alipay_dict(d):
  104. if not d:
  105. return None
  106. o = ContactInfo()
  107. if 'email' in d:
  108. o.email = d['email']
  109. if 'id_card_no' in d:
  110. o.id_card_no = d['id_card_no']
  111. if 'mobile' in d:
  112. o.mobile = d['mobile']
  113. if 'name' in d:
  114. o.name = d['name']
  115. if 'phone' in d:
  116. o.phone = d['phone']
  117. if 'tag' in d:
  118. o.tag = d['tag']
  119. if 'type' in d:
  120. o.type = d['type']
  121. return o