AddressInfo.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class AddressInfo(object):
  6. def __init__(self):
  7. self._address = None
  8. self._city_code = None
  9. self._district_code = None
  10. self._latitude = None
  11. self._longitude = None
  12. self._poiid = None
  13. self._province_code = None
  14. self._type = None
  15. @property
  16. def address(self):
  17. return self._address
  18. @address.setter
  19. def address(self, value):
  20. self._address = value
  21. @property
  22. def city_code(self):
  23. return self._city_code
  24. @city_code.setter
  25. def city_code(self, value):
  26. self._city_code = value
  27. @property
  28. def district_code(self):
  29. return self._district_code
  30. @district_code.setter
  31. def district_code(self, value):
  32. self._district_code = value
  33. @property
  34. def latitude(self):
  35. return self._latitude
  36. @latitude.setter
  37. def latitude(self, value):
  38. self._latitude = value
  39. @property
  40. def longitude(self):
  41. return self._longitude
  42. @longitude.setter
  43. def longitude(self, value):
  44. self._longitude = value
  45. @property
  46. def poiid(self):
  47. return self._poiid
  48. @poiid.setter
  49. def poiid(self, value):
  50. self._poiid = value
  51. @property
  52. def province_code(self):
  53. return self._province_code
  54. @province_code.setter
  55. def province_code(self, value):
  56. self._province_code = value
  57. @property
  58. def type(self):
  59. return self._type
  60. @type.setter
  61. def type(self, value):
  62. self._type = value
  63. def to_alipay_dict(self):
  64. params = dict()
  65. if self.address:
  66. if hasattr(self.address, 'to_alipay_dict'):
  67. params['address'] = self.address.to_alipay_dict()
  68. else:
  69. params['address'] = self.address
  70. if self.city_code:
  71. if hasattr(self.city_code, 'to_alipay_dict'):
  72. params['city_code'] = self.city_code.to_alipay_dict()
  73. else:
  74. params['city_code'] = self.city_code
  75. if self.district_code:
  76. if hasattr(self.district_code, 'to_alipay_dict'):
  77. params['district_code'] = self.district_code.to_alipay_dict()
  78. else:
  79. params['district_code'] = self.district_code
  80. if self.latitude:
  81. if hasattr(self.latitude, 'to_alipay_dict'):
  82. params['latitude'] = self.latitude.to_alipay_dict()
  83. else:
  84. params['latitude'] = self.latitude
  85. if self.longitude:
  86. if hasattr(self.longitude, 'to_alipay_dict'):
  87. params['longitude'] = self.longitude.to_alipay_dict()
  88. else:
  89. params['longitude'] = self.longitude
  90. if self.poiid:
  91. if hasattr(self.poiid, 'to_alipay_dict'):
  92. params['poiid'] = self.poiid.to_alipay_dict()
  93. else:
  94. params['poiid'] = self.poiid
  95. if self.province_code:
  96. if hasattr(self.province_code, 'to_alipay_dict'):
  97. params['province_code'] = self.province_code.to_alipay_dict()
  98. else:
  99. params['province_code'] = self.province_code
  100. if self.type:
  101. if hasattr(self.type, 'to_alipay_dict'):
  102. params['type'] = self.type.to_alipay_dict()
  103. else:
  104. params['type'] = self.type
  105. return params
  106. @staticmethod
  107. def from_alipay_dict(d):
  108. if not d:
  109. return None
  110. o = AddressInfo()
  111. if 'address' in d:
  112. o.address = d['address']
  113. if 'city_code' in d:
  114. o.city_code = d['city_code']
  115. if 'district_code' in d:
  116. o.district_code = d['district_code']
  117. if 'latitude' in d:
  118. o.latitude = d['latitude']
  119. if 'longitude' in d:
  120. o.longitude = d['longitude']
  121. if 'poiid' in d:
  122. o.poiid = d['poiid']
  123. if 'province_code' in d:
  124. o.province_code = d['province_code']
  125. if 'type' in d:
  126. o.type = d['type']
  127. return o