Skip to content

Commit 4f2592f

Browse files
committed
feat: add system_push apis
1 parent 2afc86a commit 4f2592f

19 files changed

+1223
-91
lines changed

src/main/java/com/netease/nim/server/sdk/im/v2/YunxinV2ApiServices.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import com.netease.nim.server.sdk.im.v2.signal.SignalV2Service;
2828
import com.netease.nim.server.sdk.im.v2.system_notification.CustomNotificationV2Service;
2929
import com.netease.nim.server.sdk.im.v2.system_notification.ICustomNotificationV2Service;
30+
import com.netease.nim.server.sdk.im.v2.system_push.ISystemPushV2Service;
31+
import com.netease.nim.server.sdk.im.v2.system_push.SystemPushV2Service;
3032
import com.netease.nim.server.sdk.im.v2.friend.FriendV2Service;
3133
import com.netease.nim.server.sdk.im.v2.friend.IFriendV2Service;
3234
import com.netease.nim.server.sdk.im.v2.message.IMessageV2Service;
@@ -66,6 +68,7 @@ public class YunxinV2ApiServices {
6668
private final IBlockV2Service blockService;
6769
private final IBroadcastV2Service broadcastService;
6870
private final ICustomNotificationV2Service customNotificationService;
71+
private final ISystemPushV2Service systemPushService;
6972
private final ISubscriptionV2Service subscriptionService;
7073
private final IAiSerivce aiService;
7174
private final IToolV2Service toolService;
@@ -89,6 +92,7 @@ public YunxinV2ApiServices(YunxinApiHttpClient yunxinApiHttpClient) {
8992
this.blockService = new BlockV2Service(yunxinApiHttpClient);
9093
this.broadcastService = new BroadcastV2Service(yunxinApiHttpClient);
9194
this.customNotificationService = new CustomNotificationV2Service(yunxinApiHttpClient);
95+
this.systemPushService = new SystemPushV2Service(yunxinApiHttpClient);
9296
this.subscriptionService = new SubscriptionV2Service(yunxinApiHttpClient);
9397
this.aiService = new AiService(yunxinApiHttpClient);
9498
this.toolService = new ToolV2Service(yunxinApiHttpClient);
@@ -163,6 +167,10 @@ public ICustomNotificationV2Service getCustomNotificationService() {
163167
return customNotificationService;
164168
}
165169

170+
public ISystemPushV2Service getSystemPushService() {
171+
return systemPushService;
172+
}
173+
166174
public ISubscriptionV2Service getSubscriptionService() {
167175
return subscriptionService;
168176
}

src/main/java/com/netease/nim/server/sdk/im/v2/account/request/UpdateAccountRequestV2.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,6 @@ public static class UserInformation {
168168
@JSONField(name = "extension")
169169
private String extension;
170170

171-
@JSONField(name = "email_validation_mode")
172-
private Integer emailValidationMode;
173171

174172
public String getName() {
175173
return name;
@@ -235,12 +233,5 @@ public void setExtension(String extension) {
235233
this.extension = extension;
236234
}
237235

238-
public Integer getEmailValidationMode() {
239-
return emailValidationMode;
240-
}
241-
242-
public void setEmailValidationMode(Integer emailValidationMode) {
243-
this.emailValidationMode = emailValidationMode;
244-
}
245236
}
246237
}

src/main/java/com/netease/nim/server/sdk/im/v2/system_notification/CustomNotificationV2Service.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public CustomNotificationV2Service(YunxinApiHttpClient yunxinApiHttpClient) {
3131
@Override
3232
public Result<SendCustomNotificationResponseV2> sendCustomNotification(SendCustomNotificationRequestV2 request) throws YunxinSdkException {
3333

34-
// Convert to JSON string using JSONField annotations
3534
String jsonRequestBody = JSON.toJSONString(request);
3635

3736
YunxinApiResponse apiResponse = yunxinApiHttpClient.executeV2Api(
@@ -48,7 +47,6 @@ public Result<SendCustomNotificationResponseV2> sendCustomNotification(SendCusto
4847
@Override
4948
public Result<SendBatchCustomNotificationResponseV2> sendBatchCustomNotification(SendBatchCustomNotificationRequestV2 request) throws YunxinSdkException {
5049

51-
// Convert to JSON string using JSONField annotations
5250
String jsonRequestBody = JSON.toJSONString(request);
5351

5452
YunxinApiResponse apiResponse = yunxinApiHttpClient.executeV2Api(
@@ -61,4 +59,4 @@ public Result<SendBatchCustomNotificationResponseV2> sendBatchCustomNotification
6159

6260
return ResultUtils.convert(apiResponse, SendBatchCustomNotificationResponseV2.class);
6361
}
64-
}
62+
}

src/main/java/com/netease/nim/server/sdk/im/v2/system_notification/CustomNotificationV2UrlContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ public class CustomNotificationV2UrlContext {
1414
* URL for sending batch custom notifications
1515
*/
1616
public static final String BATCH_CUSTOM_NOTIFICATION = "/im/v2/custom_notification/batch";
17-
}
17+
}

src/main/java/com/netease/nim/server/sdk/im/v2/system_notification/ICustomNotificationV2Service.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ Result<SendCustomNotificationResponseV2> sendCustomNotification(
1717

1818
Result<SendBatchCustomNotificationResponseV2> sendBatchCustomNotification(
1919
SendBatchCustomNotificationRequestV2 request) throws YunxinSdkException;
20-
}
20+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.netease.nim.server.sdk.im.v2.system_push;
2+
3+
import com.netease.nim.server.sdk.core.Result;
4+
import com.netease.nim.server.sdk.core.exception.YunxinSdkException;
5+
import com.netease.nim.server.sdk.im.v2.system_push.request.*;
6+
import com.netease.nim.server.sdk.im.v2.system_push.response.*;
7+
8+
/**
9+
* Interface for system push services
10+
*/
11+
public interface ISystemPushV2Service {
12+
13+
Result<SendPushNotificationResponseV2> sendPushNotification(
14+
SendPushNotificationRequestV2 request) throws YunxinSdkException;
15+
16+
Result<GetPushNotificationResponseV2> getPushNotification(
17+
GetPushNotificationRequestV2 request) throws YunxinSdkException;
18+
19+
Result<ListPushNotificationsResponseV2> listPushNotifications(
20+
ListPushNotificationsRequestV2 request) throws YunxinSdkException;
21+
}
22+
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package com.netease.nim.server.sdk.im.v2.system_push;
2+
3+
import com.alibaba.fastjson2.JSON;
4+
import com.netease.nim.server.sdk.core.Result;
5+
import com.netease.nim.server.sdk.core.YunxinApiHttpClient;
6+
import com.netease.nim.server.sdk.core.YunxinApiResponse;
7+
import com.netease.nim.server.sdk.core.exception.YunxinSdkException;
8+
import com.netease.nim.server.sdk.core.http.HttpMethod;
9+
import com.netease.nim.server.sdk.im.v2.system_push.request.*;
10+
import com.netease.nim.server.sdk.im.v2.system_push.response.*;
11+
import com.netease.nim.server.sdk.im.v2.util.ResultUtils;
12+
13+
import java.util.HashMap;
14+
import java.util.Map;
15+
16+
/**
17+
* Implementation of the system push service
18+
*/
19+
public class SystemPushV2Service implements ISystemPushV2Service {
20+
21+
private final YunxinApiHttpClient yunxinApiHttpClient;
22+
23+
/**
24+
* Constructor
25+
*
26+
* @param yunxinApiHttpClient HTTP client for API calls
27+
*/
28+
public SystemPushV2Service(YunxinApiHttpClient yunxinApiHttpClient) {
29+
this.yunxinApiHttpClient = yunxinApiHttpClient;
30+
}
31+
32+
@Override
33+
public Result<SendPushNotificationResponseV2> sendPushNotification(SendPushNotificationRequestV2 request) throws YunxinSdkException {
34+
35+
String jsonRequestBody = JSON.toJSONString(request);
36+
37+
YunxinApiResponse apiResponse = yunxinApiHttpClient.executeV2Api(
38+
HttpMethod.POST,
39+
SystemPushV2UrlContext.PUSH_NOTIFICATION,
40+
SystemPushV2UrlContext.PUSH_NOTIFICATION,
41+
null,
42+
jsonRequestBody
43+
);
44+
45+
return ResultUtils.convert(apiResponse, SendPushNotificationResponseV2.class);
46+
}
47+
48+
@Override
49+
public Result<GetPushNotificationResponseV2> getPushNotification(GetPushNotificationRequestV2 request) throws YunxinSdkException {
50+
51+
String url = SystemPushV2UrlContext.GET_PUSH_NOTIFICATION.replace(
52+
"{push_id}", String.valueOf(request.getPushId()));
53+
54+
YunxinApiResponse apiResponse = yunxinApiHttpClient.executeV2Api(
55+
HttpMethod.GET,
56+
SystemPushV2UrlContext.GET_PUSH_NOTIFICATION,
57+
url,
58+
null,
59+
null
60+
);
61+
62+
return ResultUtils.convert(apiResponse, GetPushNotificationResponseV2.class);
63+
}
64+
65+
@Override
66+
public Result<ListPushNotificationsResponseV2> listPushNotifications(ListPushNotificationsRequestV2 request) throws YunxinSdkException {
67+
68+
Map<String, String> queryParams = new HashMap<>();
69+
if (request.getPageToken() != null) {
70+
queryParams.put("page_token", request.getPageToken());
71+
}
72+
if (request.getLimit() != null) {
73+
queryParams.put("limit", String.valueOf(request.getLimit()));
74+
}
75+
if (request.getType() != null) {
76+
queryParams.put("type", String.valueOf(request.getType()));
77+
}
78+
79+
YunxinApiResponse apiResponse = yunxinApiHttpClient.executeV2Api(
80+
HttpMethod.GET,
81+
SystemPushV2UrlContext.PUSH_NOTIFICATION,
82+
SystemPushV2UrlContext.PUSH_NOTIFICATION,
83+
queryParams,
84+
null
85+
);
86+
87+
return ResultUtils.convert(apiResponse, ListPushNotificationsResponseV2.class);
88+
}
89+
}
90+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.netease.nim.server.sdk.im.v2.system_push;
2+
3+
/**
4+
* URL context for system push API V2
5+
*/
6+
public class SystemPushV2UrlContext {
7+
8+
/**
9+
* URL for sending push notifications to all users
10+
*/
11+
public static final String PUSH_NOTIFICATION = "/im/v2/push_notification";
12+
13+
/**
14+
* URL template for getting a single push notification
15+
* {push_id} should be replaced with the push notification ID
16+
*/
17+
public static final String GET_PUSH_NOTIFICATION = "/im/v2/push_notification/{push_id}";
18+
}
19+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.netease.nim.server.sdk.im.v2.system_push.request;
2+
3+
/**
4+
* Request for getting a single push notification
5+
*
6+
* API: GET https://open.yunxinapi.com/im/v2/push_notification/:push_id
7+
*/
8+
public class GetPushNotificationRequestV2 {
9+
10+
private Long pushId;
11+
12+
public GetPushNotificationRequestV2() {
13+
}
14+
15+
public GetPushNotificationRequestV2(Long pushId) {
16+
this.pushId = pushId;
17+
}
18+
19+
public Long getPushId() {
20+
return pushId;
21+
}
22+
23+
public void setPushId(Long pushId) {
24+
this.pushId = pushId;
25+
}
26+
}
27+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.netease.nim.server.sdk.im.v2.system_push.request;
2+
3+
/**
4+
* Request for listing push notifications with pagination
5+
*
6+
* API: GET https://open.yunxinapi.com/im/v2/push_notification
7+
*/
8+
public class ListPushNotificationsRequestV2 {
9+
10+
private String pageToken;
11+
12+
private Integer limit;
13+
14+
private Integer type;
15+
16+
public ListPushNotificationsRequestV2() {
17+
}
18+
19+
public String getPageToken() {
20+
return pageToken;
21+
}
22+
23+
public void setPageToken(String pageToken) {
24+
this.pageToken = pageToken;
25+
}
26+
27+
public Integer getLimit() {
28+
return limit;
29+
}
30+
31+
public void setLimit(Integer limit) {
32+
this.limit = limit;
33+
}
34+
35+
public Integer getType() {
36+
return type;
37+
}
38+
39+
public void setType(Integer type) {
40+
this.type = type;
41+
}
42+
}
43+

0 commit comments

Comments
 (0)