KdsPrinterModel.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class KdsPrinterModel(object):
  6. def __init__(self):
  7. self._device_id = None
  8. self._name = None
  9. self._printer_id = None
  10. @property
  11. def device_id(self):
  12. return self._device_id
  13. @device_id.setter
  14. def device_id(self, value):
  15. self._device_id = value
  16. @property
  17. def name(self):
  18. return self._name
  19. @name.setter
  20. def name(self, value):
  21. self._name = value
  22. @property
  23. def printer_id(self):
  24. return self._printer_id
  25. @printer_id.setter
  26. def printer_id(self, value):
  27. self._printer_id = value
  28. def to_alipay_dict(self):
  29. params = dict()
  30. if self.device_id:
  31. if hasattr(self.device_id, 'to_alipay_dict'):
  32. params['device_id'] = self.device_id.to_alipay_dict()
  33. else:
  34. params['device_id'] = self.device_id
  35. if self.name:
  36. if hasattr(self.name, 'to_alipay_dict'):
  37. params['name'] = self.name.to_alipay_dict()
  38. else:
  39. params['name'] = self.name
  40. if self.printer_id:
  41. if hasattr(self.printer_id, 'to_alipay_dict'):
  42. params['printer_id'] = self.printer_id.to_alipay_dict()
  43. else:
  44. params['printer_id'] = self.printer_id
  45. return params
  46. @staticmethod
  47. def from_alipay_dict(d):
  48. if not d:
  49. return None
  50. o = KdsPrinterModel()
  51. if 'device_id' in d:
  52. o.device_id = d['device_id']
  53. if 'name' in d:
  54. o.name = d['name']
  55. if 'printer_id' in d:
  56. o.printer_id = d['printer_id']
  57. return o