DeviceInfo.py 2.8 KB

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