group.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # -*- coding: utf-8 -*-
  2. from __future__ import absolute_import, unicode_literals
  3. from library.wechatpy.client.api.base import BaseWeChatAPI
  4. class MerchantGroup(BaseWeChatAPI):
  5. API_BASE_URL = 'https://api.weixin.qq.com/'
  6. def add(self, name, product_list):
  7. return self._post(
  8. 'merchant/group/add',
  9. data={
  10. 'group_detail': {
  11. 'group_name': name,
  12. 'product_list': product_list
  13. }
  14. }
  15. )
  16. def delete(self, group_id):
  17. return self._post(
  18. 'merchant/group/del',
  19. data={
  20. 'group_id': group_id
  21. }
  22. )
  23. def update(self, group_id, name):
  24. return self._post(
  25. 'merchant/group/propertymod',
  26. data={
  27. 'group_id': group_id,
  28. 'group_name': name
  29. }
  30. )
  31. def update_product(self, group_id, product):
  32. return self._post(
  33. 'merchant/group/productmod',
  34. data={
  35. 'group_id': group_id,
  36. 'product': product
  37. }
  38. )
  39. def get_all(self):
  40. res = self._get(
  41. 'merchant/group/getall',
  42. result_processor=lambda x: x['groups_detail']
  43. )
  44. return res
  45. def get(self, group_id):
  46. res = self._post(
  47. 'merchant/group/getbyid',
  48. data={
  49. 'group_id': group_id
  50. },
  51. result_processor=lambda x: x['group_detail']
  52. )
  53. return res