DataDim.py 1.8 KB

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