Skip to content

Commit

Permalink
feat: 微信小店文档地址更新;增加门店小程序相关接口 (#595)
Browse files Browse the repository at this point in the history
* update poi doc
* update poi in wxa
* black code format
  • Loading branch information
ldsink committed Aug 5, 2020
1 parent 325bf28 commit 9680ccb
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 28 deletions.
21 changes: 13 additions & 8 deletions wechatpy/client/api/poi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@


class WeChatPoi(BaseWeChatAPI):
""" 微信门店
https://developers.weixin.qq.com/doc/offiaccount/WeChat_Stores/WeChat_Store_Interface.html
"""

def add(self, poi_data):
"""
创建门店
详情请参考
http://mp.weixin.qq.com/wiki/16/8f182af4d8dcea02c56506306bdb2f4c.html
https://developers.weixin.qq.com/doc/offiaccount/WeChat_Stores/WeChat_Store_Interface.html#7
:param poi_data: 门店信息字典
:return: 返回的 JSON 数据包
Expand All @@ -21,7 +26,7 @@ def get(self, poi_id):
查询门店信息
详情请参考
http://mp.weixin.qq.com/wiki/16/8f182af4d8dcea02c56506306bdb2f4c.html
https://developers.weixin.qq.com/doc/offiaccount/WeChat_Stores/WeChat_Store_Interface.html#9
:param poi_id: 门店 ID
:return: 返回的 JSON 数据包
Expand All @@ -33,20 +38,20 @@ def list(self, begin=0, limit=20):
查询门店列表
详情请参考
http://mp.weixin.qq.com/wiki/16/8f182af4d8dcea02c56506306bdb2f4c.html
https://developers.weixin.qq.com/doc/offiaccount/WeChat_Stores/WeChat_Store_Interface.html#10
:param begin: 开始位置,0 即为从第一条开始查询
:param limit: 返回数据条数,最大允许50,默认为20
:return: 返回的 JSON 数据包
"""
return self._post("poi/getpoilist", data={"begin": begin, "limit": limit,})
return self._post("poi/getpoilist", data={"begin": begin, "limit": limit})

def update(self, poi_data):
"""
修改门店
修改门店服务信息
详情请参考
http://mp.weixin.qq.com/wiki/16/8f182af4d8dcea02c56506306bdb2f4c.html
https://developers.weixin.qq.com/doc/offiaccount/WeChat_Stores/WeChat_Store_Interface.html#11
:param poi_data: 门店信息字典
:return: 返回的 JSON 数据包
Expand All @@ -58,7 +63,7 @@ def delete(self, poi_id):
删除门店
详情请参考
http://mp.weixin.qq.com/wiki/16/8f182af4d8dcea02c56506306bdb2f4c.html
https://developers.weixin.qq.com/doc/offiaccount/WeChat_Stores/WeChat_Store_Interface.html#12
:param poi_id: 门店 ID
:return: 返回的 JSON 数据包
Expand All @@ -70,7 +75,7 @@ def get_categories(self):
获取微信门店类目表
详情请参考
http://mp.weixin.qq.com/wiki/16/8f182af4d8dcea02c56506306bdb2f4c.html
https://developers.weixin.qq.com/doc/offiaccount/WeChat_Stores/WeChat_Store_Interface.html#13
:return: 门店类目表
"""
Expand Down
154 changes: 134 additions & 20 deletions wechatpy/client/api/wxa.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def send_subscribe_message(self, user_id, template_id, data, page=None):
详情请参考
https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.send.html
"""
subs_data = optionaldict(touser=user_id, template_id=template_id, page=page, data=data,)
subs_data = optionaldict(touser=user_id, template_id=template_id, page=page, data=data)
return self._post("cgi-bin/message/subscribe/send", data=subs_data)

def modify_domain(
Expand Down Expand Up @@ -123,7 +123,7 @@ def bind_tester(self, wechat_id):
:param wechat_id: 微信号
"""
return self._post("wxa/bind_tester", data={"wechatid": wechat_id,})
return self._post("wxa/bind_tester", data={"wechatid": wechat_id})

def unbind_tester(self, wechat_id):
"""
Expand All @@ -133,7 +133,7 @@ def unbind_tester(self, wechat_id):
:param wechat_id: 微信号
"""
return self._post("wxa/unbind_tester", data={"wechatid": wechat_id,})
return self._post("wxa/unbind_tester", data={"wechatid": wechat_id})

def commit(self, template_id, ext_json, version, description):
"""
Expand All @@ -148,7 +148,7 @@ def commit(self, template_id, ext_json, version, description):
"""
return self._post(
"wxa/commit",
data={"template_id": template_id, "ext_json": ext_json, "user_version": version, "user_desc": description,},
data={"template_id": template_id, "ext_json": ext_json, "user_version": version, "user_desc": description},
)

def get_qrcode(self):
Expand All @@ -170,7 +170,7 @@ def get_category(self):
:rtype: list[dict]
"""
return self._get("wxa/get_category", result_processor=lambda x: x["category_list"],)
return self._get("wxa/get_category", result_processor=lambda x: x["category_list"])

def get_page(self):
"""
Expand All @@ -180,7 +180,7 @@ def get_page(self):
:rtype: list
"""
return self._get("wxa/get_page", result_processor=lambda x: x["page_list"],)
return self._get("wxa/get_page", result_processor=lambda x: x["page_list"])

def submit_audit(self, data):
"""
Expand Down Expand Up @@ -218,7 +218,7 @@ def get_audit_status(self, auditid):
:type auditid: int
:return: 一个包含 status, reason 的 dict。status 0为审核成功,1为审核失败,2为审核中。
"""
return self._post("wxa/get_auditstatus", data={"auditid": auditid,},)
return self._post("wxa/get_auditstatus", data={"auditid": auditid})

def get_latest_audit_status(self):
"""
Expand All @@ -236,7 +236,7 @@ def release(self):
详情请参考
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1489140610_Uavc4
"""
return self._post("wxa/release", data={},)
return self._post("wxa/release", data={})

def change_visit_status(self, close=False):
"""
Expand All @@ -247,7 +247,7 @@ def change_visit_status(self, close=False):
:param close: close 为 True 时会关闭小程序线上代码的可见状态。
:type close: bool
"""
return self._post("wxa/change_visitstatus", data={"action": "close" if close else "open",},)
return self._post("wxa/change_visitstatus", data={"action": "close" if close else "open"})

def list_library_templates(self, offset=0, count=20):
"""
Expand All @@ -262,7 +262,7 @@ def list_library_templates(self, offset=0, count=20):
:return: 带有 total_count 与 list 的数据
:rtype: dict
"""
return self._post("cgi-bin/wxopen/template/library/list", data={"offset": offset, "count": count,},)
return self._post("cgi-bin/wxopen/template/library/list", data={"offset": offset, "count": count})

def get_library_template(self, template_short_id):
"""
Expand All @@ -273,7 +273,7 @@ def get_library_template(self, template_short_id):
:param template_short_id: 模板标题ID
:rtype: dict
"""
return self._post("cgi-bin/wxopen/template/library/get", data={"id": template_short_id,},)
return self._post("cgi-bin/wxopen/template/library/get", data={"id": template_short_id})

def list_templates(self, offset=0, count=20):
"""
Expand All @@ -290,7 +290,7 @@ def list_templates(self, offset=0, count=20):
"""
return self._post(
"cgi-bin/wxopen/template/list",
data={"offset": offset, "count": count,},
data={"offset": offset, "count": count},
result_processor=lambda x: x["list"],
)

Expand All @@ -307,7 +307,7 @@ def add_template(self, template_short_id, keyword_id_list):
"""
return self._post(
"cgi-bin/wxopen/template/add",
data={"id": template_short_id, "keyword_id_list": keyword_id_list,},
data={"id": template_short_id, "keyword_id_list": keyword_id_list},
result_processor=lambda x: x["template_id"],
)

Expand All @@ -319,7 +319,7 @@ def del_template(self, template_id):
:param template_id: 模板ID
"""
return self._post("cgi-bin/wxopen/template/del", data={"template_id": template_id,},)
return self._post("cgi-bin/wxopen/template/del", data={"template_id": template_id})

def create_open(self, appid):
"""
Expand All @@ -330,7 +330,7 @@ def create_open(self, appid):
:param appid: 授权公众号或小程序的 appid
:return: 开放平台的 appid
"""
return self._post("cgi-bin/open/create", data={"appid": appid,}, result_processor=lambda x: x["open_appid"],)
return self._post("cgi-bin/open/create", data={"appid": appid}, result_processor=lambda x: x["open_appid"])

def get_open(self, appid):
"""
Expand All @@ -341,7 +341,7 @@ def get_open(self, appid):
:param appid: 授权公众号或小程序的 appid
:return: 开放平台的 appid
"""
return self._post("cgi-bin/open/get", data={"appid": appid,}, result_processor=lambda x: x["open_appid"],)
return self._post("cgi-bin/open/get", data={"appid": appid}, result_processor=lambda x: x["open_appid"])

def bind_open(self, appid, open_appid):
"""
Expand All @@ -352,7 +352,7 @@ def bind_open(self, appid, open_appid):
:param appid: 授权公众号或小程序的 appid
:param open_appid: 开放平台帐号 appid
"""
return self._post("cgi-bin/open/bind", data={"appid": appid, "open_appid": open_appid,})
return self._post("cgi-bin/open/bind", data={"appid": appid, "open_appid": open_appid})

def unbind_open(self, appid, open_appid):
"""
Expand All @@ -363,7 +363,7 @@ def unbind_open(self, appid, open_appid):
:param appid: 授权公众号或小程序的 appid
:param open_appid: 开放平台帐号 appid
"""
return self._post("cgi-bin/open/unbind", data={"appid": appid, "open_appid": open_appid,})
return self._post("cgi-bin/open/unbind", data={"appid": appid, "open_appid": open_appid})

def code_to_session(self, js_code):
"""
Expand Down Expand Up @@ -393,7 +393,7 @@ def check_image_security(self, media):
:param media: 要检测的图片文件,格式支持PNG、JPEG、JPG、GIF,图片尺寸不超过 750px x 1334px
:return:
"""
return self._post("wxa/img_sec_check", files={"media": media,})
return self._post("wxa/img_sec_check", files={"media": media})

def check_text_security(self, content):
"""
Expand All @@ -404,7 +404,7 @@ def check_text_security(self, content):
:param content: 要检测的文本内容,长度不超过 500KB
:return:
"""
return self._post("wxa/msg_sec_check", data={"content": content,})
return self._post("wxa/msg_sec_check", data={"content": content})

def speed_up_audit(self, auditid):
"""
Expand Down Expand Up @@ -445,3 +445,117 @@ def get_paid_unionid(self, openid, transaction_id=None, mch_id=None, out_trade_n
},
result_processor=lambda x: x["unionid"],
)

def get_merchant_category(self) -> dict:
"""
拉取门店小程序类目
https://developers.weixin.qq.com/doc/offiaccount/WeChat_Stores/WeChat_Shop_Miniprogram_Interface.html#5
"""
return self._get("wxa/get_merchant_category")

def apply_merchant(self, data: dict) -> dict:
"""
创建门店小程序
创建门店小程序提交后需要公众号管理员确认通过后才可进行审核。如果主管理员24小时超时未确认,才能再次提交。
https://developers.weixin.qq.com/doc/offiaccount/WeChat_Stores/WeChat_Shop_Miniprogram_Interface.html#6
:param data: 门店数据,具体请参考文档
"""
return self._post("wxa/applywxastore", data=data)

def get_merchant_audit_info(self) -> dict:
"""
查询门店小程序审核结果
https://developers.weixin.qq.com/doc/offiaccount/WeChat_Stores/WeChat_Shop_Miniprogram_Interface.html#7
"""
return self._get("wxa/get_merchant_audit_info")

def modify_merchant(self, data: dict) -> dict:
"""
修改门店小程序信息
https://developers.weixin.qq.com/doc/offiaccount/WeChat_Stores/WeChat_Shop_Miniprogram_Interface.html#8
:param data: 具体请参考文档
:return: 参考文档
"""
return self._post("wxa/modify_merchant", data=data)

def get_district(self) -> dict:
"""
从腾讯地图拉取省市区信息
https://developers.weixin.qq.com/doc/offiaccount/WeChat_Stores/WeChat_Shop_Miniprogram_Interface.html#9
:return: 参考文档
"""
return self._get("wxa/get_district")

def search_map_poi(self, data: dict) -> dict:
"""
在腾讯地图中搜索门店
https://developers.weixin.qq.com/doc/offiaccount/WeChat_Stores/WeChat_Shop_Miniprogram_Interface.html#10
:param data: 具体请参考文档
:return: 参考文档
"""
return self._post("wxa/search_map_poi", data=data)

def create_map_poi(self, data: dict) -> dict:
"""
在腾讯地图中创建门店
https://developers.weixin.qq.com/doc/offiaccount/WeChat_Stores/WeChat_Shop_Miniprogram_Interface.html#11
:param data: 具体请参考文档
:return: 参考文档
"""
return self._post("wxa/create_map_poi", data=data)

def add_store(self, data: dict) -> dict:
"""
添加门店
https://developers.weixin.qq.com/doc/offiaccount/WeChat_Stores/WeChat_Shop_Miniprogram_Interface.html#12
:param data: 具体请参考文档
:return: 参考文档
"""
return self._post("wxa/add_store", data=data)

def update_store(self, data: dict) -> dict:
"""
更新门店信息
https://developers.weixin.qq.com/doc/offiaccount/WeChat_Stores/WeChat_Shop_Miniprogram_Interface.html#13
:param data: 具体请参考文档
:return: 参考文档
"""
return self._post("wxa/update_store", data=data)

def get_store_info(self, poi_id: str) -> dict:
"""
获取单个门店信息
https://developers.weixin.qq.com/doc/offiaccount/WeChat_Stores/WeChat_Shop_Miniprogram_Interface.html#14
:param poi_id: 为门店小程序添加门店,审核成功后返回的门店id
:return: 门店信息
"""
return self._post("wxa/get_store_info", data={"poi_id": poi_id})

def get_store_list(self, offset: int = 0, limit: int = 10) -> dict:
"""
获取门店信息列表
https://developers.weixin.qq.com/doc/offiaccount/WeChat_Stores/WeChat_Shop_Miniprogram_Interface.html#15
:param offset: 获取门店列表的初始偏移位置,从0开始计数
:param limit: 获取门店个数
:return: 参考文档
"""
return self._post("wxa/get_store_list", data={"offset": offset, "limit": limit})

def del_store(self, poi_id: str) -> dict:
"""
删除门店
https://developers.weixin.qq.com/doc/offiaccount/WeChat_Stores/WeChat_Shop_Miniprogram_Interface.html#16
:param poi_id: 为门店小程序添加门店,审核成功后返回的门店id
:return: 参考文档
"""
return self._post("wxa/del_store", data={"poi_id": poi_id})

0 comments on commit 9680ccb

Please sign in to comment.