Skip to content

Commit 9a616de

Browse files
authored
🐛 #4110 【小程序】修正服务卡片几个接口的地址
1 parent f994a17 commit 9a616de

5 files changed

Lines changed: 71 additions & 6 deletions

File tree

weixin-java-miniapp/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
<groupId>org.apache.maven.plugins</groupId>
116116
<artifactId>maven-surefire-plugin</artifactId>
117117
<configuration>
118+
<skip>false</skip>
118119
<suiteXmlFiles>
119120
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
120121
</suiteXmlFiles>

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaSubscribeService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public interface WxMaSubscribeService {
122122
* 激活与更新服务卡片
123123
*
124124
* 详情请见: <a href="https://developers.weixin.qq.com/miniprogram/dev/server/API/mp-message-management/subscribe-message/api_setusernotify.html">激活与更新服务卡片</a>
125-
* 接口url格式: POST https://api.weixin.qq.com/wxa/setusernotify?access_token=ACCESS_TOKEN
125+
* 接口url格式: POST https://api.weixin.qq.com/wxa/set_user_notify?access_token=ACCESS_TOKEN
126126
* </pre>
127127
*
128128
* @param request 请求参数
@@ -135,7 +135,7 @@ public interface WxMaSubscribeService {
135135
* 更新服务卡片扩展信息
136136
*
137137
* 详情请见: <a href="https://developers.weixin.qq.com/miniprogram/dev/server/API/mp-message-management/subscribe-message/api_setusernotifyext.html">更新服务卡片扩展信息</a>
138-
* 接口url格式: POST https://api.weixin.qq.com/wxa/setusernotifyext?access_token=ACCESS_TOKEN
138+
* 接口url格式: POST https://api.weixin.qq.com/wxa/set_user_notifyext?access_token=ACCESS_TOKEN
139139
* </pre>
140140
*
141141
* @param request 请求参数
@@ -148,7 +148,7 @@ public interface WxMaSubscribeService {
148148
* 查询服务卡片状态
149149
*
150150
* 详情请见: <a href="https://developers.weixin.qq.com/miniprogram/dev/server/API/mp-message-management/subscribe-message/api_getusernotify.html">查询服务卡片状态</a>
151-
* 接口url格式: POST https://api.weixin.qq.com/wxa/getusernotify?access_token=ACCESS_TOKEN
151+
* 接口url格式: POST https://api.weixin.qq.com/wxa/get_user_notify?access_token=ACCESS_TOKEN
152152
* </pre>
153153
*
154154
* @param request 请求参数

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,13 @@ public interface Subscribe {
370370
String SUBSCRIBE_MSG_SEND_URL = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send";
371371

372372
/** 激活与更新服务卡片 */
373-
String SERVICE_NOTIFY_SET_URL = "https://api.weixin.qq.com/wxa/setusernotify";
373+
String SERVICE_NOTIFY_SET_URL = "https://api.weixin.qq.com/wxa/set_user_notify";
374374

375375
/** 更新服务卡片扩展信息 */
376-
String SERVICE_NOTIFY_SET_EXT_URL = "https://api.weixin.qq.com/wxa/setusernotifyext";
376+
String SERVICE_NOTIFY_SET_EXT_URL = "https://api.weixin.qq.com/wxa/set_user_notifyext";
377377

378378
/** 查询服务卡片状态 */
379-
String SERVICE_NOTIFY_GET_URL = "https://api.weixin.qq.com/wxa/getusernotify";
379+
String SERVICE_NOTIFY_GET_URL = "https://api.weixin.qq.com/wxa/get_user_notify";
380380
}
381381

382382
public interface User {
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package cn.binarywang.wx.miniapp.api.impl;
2+
3+
import cn.binarywang.wx.miniapp.api.WxMaService;
4+
import cn.binarywang.wx.miniapp.api.WxMaSubscribeService;
5+
import cn.binarywang.wx.miniapp.bean.WxMaGetUserNotifyRequest;
6+
import cn.binarywang.wx.miniapp.bean.WxMaServiceNotifyExtRequest;
7+
import cn.binarywang.wx.miniapp.bean.WxMaServiceNotifyRequest;
8+
import me.chanjar.weixin.common.error.WxErrorException;
9+
import org.mockito.Mockito;
10+
import org.testng.annotations.Test;
11+
12+
import static org.mockito.ArgumentMatchers.anyString;
13+
import static org.mockito.ArgumentMatchers.eq;
14+
import static org.mockito.Mockito.verify;
15+
import static org.mockito.Mockito.when;
16+
17+
public class WxMaSubscribeServiceImplUrlTest {
18+
19+
@Test
20+
public void setUserNotifyUsesOfficialEndpoint() throws WxErrorException {
21+
WxMaService service = successService();
22+
23+
subscribeService(service).setUserNotify(WxMaServiceNotifyRequest.builder().build());
24+
25+
verify(service).post(eq("https://api.weixin.qq.com/wxa/set_user_notify"), anyString());
26+
}
27+
28+
@Test
29+
public void setUserNotifyExtUsesOfficialEndpoint() throws WxErrorException {
30+
WxMaService service = successService();
31+
32+
subscribeService(service).setUserNotifyExt(WxMaServiceNotifyExtRequest.builder().build());
33+
34+
verify(service).post(eq("https://api.weixin.qq.com/wxa/set_user_notifyext"), anyString());
35+
}
36+
37+
@Test
38+
public void getUserNotifyUsesOfficialEndpoint() throws WxErrorException {
39+
WxMaService service = successService();
40+
41+
subscribeService(service).getUserNotify(WxMaGetUserNotifyRequest.builder().build());
42+
43+
verify(service).post(eq("https://api.weixin.qq.com/wxa/get_user_notify"), anyString());
44+
}
45+
46+
private WxMaSubscribeService subscribeService(WxMaService service) {
47+
return new WxMaSubscribeServiceImpl(service);
48+
}
49+
50+
private WxMaService successService() throws WxErrorException {
51+
WxMaService service = Mockito.mock(WxMaService.class);
52+
when(service.post(anyString(), anyString())).thenReturn("{\"errcode\":0,\"errmsg\":\"ok\"}");
53+
return service;
54+
}
55+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
2+
3+
<suite name="weixin-java-miniapp-unit-tests" verbose="1">
4+
<test name="Unit_Test">
5+
<classes>
6+
<class name="cn.binarywang.wx.miniapp.api.impl.WxMaSubscribeServiceImplUrlTest"/>
7+
</classes>
8+
</test>
9+
</suite>

0 commit comments

Comments
 (0)