🆕 #2642【企业微信】增加客户群加入群聊管理相关接口

This commit is contained in:
Jc826
2022-05-13 16:29:56 +08:00
committed by GitHub
parent 6177ca05b8
commit 458e7c3d24
6 changed files with 253 additions and 5 deletions

View File

@@ -56,7 +56,6 @@ public interface WxCpExternalContactService {
* @throws WxErrorException the wx error exception
*/
WxCpContactWayInfo getContactWay(@NonNull String configId) throws WxErrorException;
/**
* 更新企业已配置的「联系我」方式
*
@@ -171,6 +170,50 @@ public interface WxCpExternalContactService {
*/
String unionidToExternalUserid(@NotNull String unionid,String openid) throws WxErrorException;
/**
*
* 配置客户群进群方式
* 企业可以在管理后台-客户联系中配置「加入群聊」的二维码或者小程序按钮,客户通过扫描二维码或点击小程序上的按钮,即可加入特定的客户群。
* 企业可通过此接口为具有客户联系功能的成员生成专属的二维码或者小程序按钮。
* 如果配置的是小程序按钮,需要开发者的小程序接入小程序插件。
* 注意:
* 通过API添加的配置不会在管理端进行展示每个企业可通过API最多配置50万个「加入群聊」(与「联系我」共用50万的额度)。
* 文档地址https://developer.work.weixin.qq.com/document/path/92229
* @param wxCpGroupJoinWayInfo
* @return {@link WxCpGroupJoinWayResult}
* @throws WxErrorException
*/
WxCpGroupJoinWayResult addJoinWay(@NonNull WxCpGroupJoinWayInfo wxCpGroupJoinWayInfo) throws WxErrorException;
/**
*更新客户群进群方式配置
* 更新进群方式配置信息。注意:使用覆盖的方式更新。
* 文档地址https://developer.work.weixin.qq.com/document/path/92229
* @param wxCpGroupJoinWayInfo
* @return
* @throws WxErrorException
*/
WxCpBaseResp updateJoinWay(@NonNull WxCpGroupJoinWayInfo wxCpGroupJoinWayInfo) throws WxErrorException;
/**
* 获取客户群进群方式配置
* 获取企业配置的群二维码或小程序按钮。
* 文档地址https://developer.work.weixin.qq.com/document/path/92229
* @param configId
* @return
* @throws WxErrorException
*/
WxCpGroupJoinWayInfo getJoinWay(@NonNull String configId) throws WxErrorException;
/**
* 删除客户群进群方式配置
* 文档地址https://developer.work.weixin.qq.com/document/path/92229
* @param configId
* @return
* @throws WxErrorException
*/
WxCpBaseResp delJoinWay( @NonNull String configId) throws WxErrorException;
/**
* 代开发应用external_userid转换
* <pre>
@@ -1025,4 +1068,5 @@ public interface WxCpExternalContactService {
* @param productId 商品id
*/
void deleteProductAlbum(String productId) throws WxErrorException;
}

View File

@@ -882,5 +882,43 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
this.mainService.post(url, o.toString());
}
@Override
public WxCpGroupJoinWayResult addJoinWay(@NonNull WxCpGroupJoinWayInfo wxCpGroupJoinWayInfo) throws WxErrorException {
if (wxCpGroupJoinWayInfo.getJoinWay().getChatIdList() != null && wxCpGroupJoinWayInfo.getJoinWay().getChatIdList().size() > 5) {
throw new WxRuntimeException("使用该配置的客户群ID列表支持5个");
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_JOIN_WAY);
String responseContent = this.mainService.post(url, wxCpGroupJoinWayInfo.getJoinWay().toJson());
return WxCpGroupJoinWayResult.fromJson(responseContent);
}
@Override
public WxCpBaseResp updateJoinWay(@NonNull WxCpGroupJoinWayInfo wxCpGroupJoinWayInfo) throws WxErrorException {
if (wxCpGroupJoinWayInfo.getJoinWay().getChatIdList() != null && wxCpGroupJoinWayInfo.getJoinWay().getChatIdList().size() > 5) {
throw new WxRuntimeException("使用该配置的客户群ID列表支持5个");
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_JOIN_WAY);
String responseContent = this.mainService.post(url, wxCpGroupJoinWayInfo.getJoinWay().toJson());
return WxCpBaseResp.fromJson(responseContent);
}
@Override
public WxCpGroupJoinWayInfo getJoinWay(String configId) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("config_id", configId);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_JOIN_WAY);
String responseContent = this.mainService.post(url,json);
return WxCpGroupJoinWayInfo.fromJson(responseContent);
}
@Override
public WxCpBaseResp delJoinWay(@NonNull String configId) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("config_id", configId);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(DEL_JOIN_WAY);
String responseContent = this.mainService.post(url, json);
return WxCpBaseResp.fromJson(responseContent);
}
}