poi.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # -*- coding: utf-8 -*-
  2. from __future__ import absolute_import, unicode_literals
  3. from library.wechatpy.client.api.base import BaseWeChatAPI
  4. class WeChatPoi(BaseWeChatAPI):
  5. def add(self, poi_data):
  6. """
  7. 创建门店
  8. 详情请参考
  9. http://mp.weixin.qq.com/wiki/16/8f182af4d8dcea02c56506306bdb2f4c.html
  10. :param poi_data: 门店信息字典
  11. :return: 返回的 JSON 数据包
  12. """
  13. return self._post('poi/addpoi', data=poi_data)
  14. def get(self, poi_id):
  15. """
  16. 查询门店信息
  17. 详情请参考
  18. http://mp.weixin.qq.com/wiki/16/8f182af4d8dcea02c56506306bdb2f4c.html
  19. :param poi_id: 门店 ID
  20. :return: 返回的 JSON 数据包
  21. """
  22. return self._post('poi/getpoi', data={'poi_id': poi_id})
  23. def list(self, begin=0, limit=20):
  24. """
  25. 查询门店列表
  26. 详情请参考
  27. http://mp.weixin.qq.com/wiki/16/8f182af4d8dcea02c56506306bdb2f4c.html
  28. :param begin: 开始位置,0 即为从第一条开始查询
  29. :param limit: 返回数据条数,最大允许50,默认为20
  30. :return: 返回的 JSON 数据包
  31. """
  32. return self._post(
  33. 'poi/getpoilist',
  34. data={
  35. 'begin': begin,
  36. 'limit': limit,
  37. }
  38. )
  39. def update(self, poi_data):
  40. """
  41. 修改门店
  42. 详情请参考
  43. http://mp.weixin.qq.com/wiki/16/8f182af4d8dcea02c56506306bdb2f4c.html
  44. :param poi_data: 门店信息字典
  45. :return: 返回的 JSON 数据包
  46. """
  47. return self._post('poi/updatepoi', data=poi_data)
  48. def delete(self, poi_id):
  49. """
  50. 删除门店
  51. 详情请参考
  52. http://mp.weixin.qq.com/wiki/16/8f182af4d8dcea02c56506306bdb2f4c.html
  53. :param poi_id: 门店 ID
  54. :return: 返回的 JSON 数据包
  55. """
  56. return self._post('poi/delpoi', data={'poi_id': poi_id})
  57. def get_categories(self):
  58. """
  59. 获取微信门店类目表
  60. 详情请参考
  61. http://mp.weixin.qq.com/wiki/16/8f182af4d8dcea02c56506306bdb2f4c.html
  62. :return: 门店类目表
  63. """
  64. res = self._get(
  65. 'api_getwxcategory',
  66. result_processor=lambda x: x['category_list']
  67. )
  68. return res