SimpleMockModel.py 2.7 KB

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