Position.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class Position(object):
  6. def __init__(self):
  7. self._city_code = None
  8. self._device_id = None
  9. self._device_type = None
  10. self._scene = None
  11. self._station_code = None
  12. self._station_level = None
  13. @property
  14. def city_code(self):
  15. return self._city_code
  16. @city_code.setter
  17. def city_code(self, value):
  18. self._city_code = value
  19. @property
  20. def device_id(self):
  21. return self._device_id
  22. @device_id.setter
  23. def device_id(self, value):
  24. self._device_id = value
  25. @property
  26. def device_type(self):
  27. return self._device_type
  28. @device_type.setter
  29. def device_type(self, value):
  30. self._device_type = value
  31. @property
  32. def scene(self):
  33. return self._scene
  34. @scene.setter
  35. def scene(self, value):
  36. self._scene = value
  37. @property
  38. def station_code(self):
  39. return self._station_code
  40. @station_code.setter
  41. def station_code(self, value):
  42. self._station_code = value
  43. @property
  44. def station_level(self):
  45. return self._station_level
  46. @station_level.setter
  47. def station_level(self, value):
  48. self._station_level = value
  49. def to_alipay_dict(self):
  50. params = dict()
  51. if self.city_code:
  52. if hasattr(self.city_code, 'to_alipay_dict'):
  53. params['city_code'] = self.city_code.to_alipay_dict()
  54. else:
  55. params['city_code'] = self.city_code
  56. if self.device_id:
  57. if hasattr(self.device_id, 'to_alipay_dict'):
  58. params['device_id'] = self.device_id.to_alipay_dict()
  59. else:
  60. params['device_id'] = self.device_id
  61. if self.device_type:
  62. if hasattr(self.device_type, 'to_alipay_dict'):
  63. params['device_type'] = self.device_type.to_alipay_dict()
  64. else:
  65. params['device_type'] = self.device_type
  66. if self.scene:
  67. if hasattr(self.scene, 'to_alipay_dict'):
  68. params['scene'] = self.scene.to_alipay_dict()
  69. else:
  70. params['scene'] = self.scene
  71. if self.station_code:
  72. if hasattr(self.station_code, 'to_alipay_dict'):
  73. params['station_code'] = self.station_code.to_alipay_dict()
  74. else:
  75. params['station_code'] = self.station_code
  76. if self.station_level:
  77. if hasattr(self.station_level, 'to_alipay_dict'):
  78. params['station_level'] = self.station_level.to_alipay_dict()
  79. else:
  80. params['station_level'] = self.station_level
  81. return params
  82. @staticmethod
  83. def from_alipay_dict(d):
  84. if not d:
  85. return None
  86. o = Position()
  87. if 'city_code' in d:
  88. o.city_code = d['city_code']
  89. if 'device_id' in d:
  90. o.device_id = d['device_id']
  91. if 'device_type' in d:
  92. o.device_type = d['device_type']
  93. if 'scene' in d:
  94. o.scene = d['scene']
  95. if 'station_code' in d:
  96. o.station_code = d['station_code']
  97. if 'station_level' in d:
  98. o.station_level = d['station_level']
  99. return o