Addresscomponent.py 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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.Building import Building
  6. from alipay.aop.api.domain.Businessarea import Businessarea
  7. from alipay.aop.api.domain.Neighborhood import Neighborhood
  8. from alipay.aop.api.domain.Streetnumber import Streetnumber
  9. class Addresscomponent(object):
  10. def __init__(self):
  11. self._adcode = None
  12. self._building = None
  13. self._business_areas = None
  14. self._city = None
  15. self._citycode = None
  16. self._country = None
  17. self._district = None
  18. self._neighborhood = None
  19. self._province = None
  20. self._street_number = None
  21. self._towncode = None
  22. self._township = None
  23. @property
  24. def adcode(self):
  25. return self._adcode
  26. @adcode.setter
  27. def adcode(self, value):
  28. self._adcode = value
  29. @property
  30. def building(self):
  31. return self._building
  32. @building.setter
  33. def building(self, value):
  34. if isinstance(value, Building):
  35. self._building = value
  36. else:
  37. self._building = Building.from_alipay_dict(value)
  38. @property
  39. def business_areas(self):
  40. return self._business_areas
  41. @business_areas.setter
  42. def business_areas(self, value):
  43. if isinstance(value, list):
  44. self._business_areas = list()
  45. for i in value:
  46. if isinstance(i, Businessarea):
  47. self._business_areas.append(i)
  48. else:
  49. self._business_areas.append(Businessarea.from_alipay_dict(i))
  50. @property
  51. def city(self):
  52. return self._city
  53. @city.setter
  54. def city(self, value):
  55. self._city = value
  56. @property
  57. def citycode(self):
  58. return self._citycode
  59. @citycode.setter
  60. def citycode(self, value):
  61. self._citycode = value
  62. @property
  63. def country(self):
  64. return self._country
  65. @country.setter
  66. def country(self, value):
  67. self._country = value
  68. @property
  69. def district(self):
  70. return self._district
  71. @district.setter
  72. def district(self, value):
  73. self._district = value
  74. @property
  75. def neighborhood(self):
  76. return self._neighborhood
  77. @neighborhood.setter
  78. def neighborhood(self, value):
  79. if isinstance(value, Neighborhood):
  80. self._neighborhood = value
  81. else:
  82. self._neighborhood = Neighborhood.from_alipay_dict(value)
  83. @property
  84. def province(self):
  85. return self._province
  86. @province.setter
  87. def province(self, value):
  88. self._province = value
  89. @property
  90. def street_number(self):
  91. return self._street_number
  92. @street_number.setter
  93. def street_number(self, value):
  94. if isinstance(value, Streetnumber):
  95. self._street_number = value
  96. else:
  97. self._street_number = Streetnumber.from_alipay_dict(value)
  98. @property
  99. def towncode(self):
  100. return self._towncode
  101. @towncode.setter
  102. def towncode(self, value):
  103. self._towncode = value
  104. @property
  105. def township(self):
  106. return self._township
  107. @township.setter
  108. def township(self, value):
  109. self._township = value
  110. def to_alipay_dict(self):
  111. params = dict()
  112. if self.adcode:
  113. if hasattr(self.adcode, 'to_alipay_dict'):
  114. params['adcode'] = self.adcode.to_alipay_dict()
  115. else:
  116. params['adcode'] = self.adcode
  117. if self.building:
  118. if hasattr(self.building, 'to_alipay_dict'):
  119. params['building'] = self.building.to_alipay_dict()
  120. else:
  121. params['building'] = self.building
  122. if self.business_areas:
  123. if isinstance(self.business_areas, list):
  124. for i in range(0, len(self.business_areas)):
  125. element = self.business_areas[i]
  126. if hasattr(element, 'to_alipay_dict'):
  127. self.business_areas[i] = element.to_alipay_dict()
  128. if hasattr(self.business_areas, 'to_alipay_dict'):
  129. params['business_areas'] = self.business_areas.to_alipay_dict()
  130. else:
  131. params['business_areas'] = self.business_areas
  132. if self.city:
  133. if hasattr(self.city, 'to_alipay_dict'):
  134. params['city'] = self.city.to_alipay_dict()
  135. else:
  136. params['city'] = self.city
  137. if self.citycode:
  138. if hasattr(self.citycode, 'to_alipay_dict'):
  139. params['citycode'] = self.citycode.to_alipay_dict()
  140. else:
  141. params['citycode'] = self.citycode
  142. if self.country:
  143. if hasattr(self.country, 'to_alipay_dict'):
  144. params['country'] = self.country.to_alipay_dict()
  145. else:
  146. params['country'] = self.country
  147. if self.district:
  148. if hasattr(self.district, 'to_alipay_dict'):
  149. params['district'] = self.district.to_alipay_dict()
  150. else:
  151. params['district'] = self.district
  152. if self.neighborhood:
  153. if hasattr(self.neighborhood, 'to_alipay_dict'):
  154. params['neighborhood'] = self.neighborhood.to_alipay_dict()
  155. else:
  156. params['neighborhood'] = self.neighborhood
  157. if self.province:
  158. if hasattr(self.province, 'to_alipay_dict'):
  159. params['province'] = self.province.to_alipay_dict()
  160. else:
  161. params['province'] = self.province
  162. if self.street_number:
  163. if hasattr(self.street_number, 'to_alipay_dict'):
  164. params['street_number'] = self.street_number.to_alipay_dict()
  165. else:
  166. params['street_number'] = self.street_number
  167. if self.towncode:
  168. if hasattr(self.towncode, 'to_alipay_dict'):
  169. params['towncode'] = self.towncode.to_alipay_dict()
  170. else:
  171. params['towncode'] = self.towncode
  172. if self.township:
  173. if hasattr(self.township, 'to_alipay_dict'):
  174. params['township'] = self.township.to_alipay_dict()
  175. else:
  176. params['township'] = self.township
  177. return params
  178. @staticmethod
  179. def from_alipay_dict(d):
  180. if not d:
  181. return None
  182. o = Addresscomponent()
  183. if 'adcode' in d:
  184. o.adcode = d['adcode']
  185. if 'building' in d:
  186. o.building = d['building']
  187. if 'business_areas' in d:
  188. o.business_areas = d['business_areas']
  189. if 'city' in d:
  190. o.city = d['city']
  191. if 'citycode' in d:
  192. o.citycode = d['citycode']
  193. if 'country' in d:
  194. o.country = d['country']
  195. if 'district' in d:
  196. o.district = d['district']
  197. if 'neighborhood' in d:
  198. o.neighborhood = d['neighborhood']
  199. if 'province' in d:
  200. o.province = d['province']
  201. if 'street_number' in d:
  202. o.street_number = d['street_number']
  203. if 'towncode' in d:
  204. o.towncode = d['towncode']
  205. if 'township' in d:
  206. o.township = d['township']
  207. return o