🎨 【企业微信】重构规范化客户联系聊天敏感词管理的相关接口和文档

This commit is contained in:
Binary Wang 2022-11-06 12:00:01 +08:00
parent 43a460a28b
commit 1e13645f72
6 changed files with 239 additions and 335 deletions

View File

@ -5,6 +5,8 @@ import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.bean.external.*;
import me.chanjar.weixin.cp.bean.external.contact.*;
import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRule;
import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRuleAddRequest;
import java.io.File;
import java.io.IOException;
@ -249,8 +251,9 @@ public interface WxCpExternalContactService {
* 需要使用自建应用或基础应用的access_token
* 客户的跟进人或者用户所在客户群的群主需要同时在access_token和source_agentid所对应应用的可见范围内
* </pre>
*
* @param externalUserid 服务商主体的external_userid必须是source_agentid对应的应用所获取
* @param sourceAgentId 企业授权的代开发自建应用或第三方应用的agentid
* @param sourceAgentId 企业授权的代开发自建应用或第三方应用的agentid
* @return
* @throws WxErrorException
*/
@ -614,13 +617,14 @@ public interface WxCpExternalContactService {
/**
* 企业可通过此接口将在职成员为群主的群分配给另一个客服成员
* <per>
* 注意
* 注意
* 继承给的新群主必须是配置了客户联系功能的成员
* 继承给的新群主必须有设置实名
* 继承给的新群主必须有激活企业微信
* 同一个人的群限制每天最多分配300个给新群主
* 为保障客户服务体验90个自然日内在职成员的每个客户群仅可被转接2次
* </pre>
*
* @param chatIds 需要转群主的客户群ID列表取值范围 1 ~ 100
* @param newOwner 新群主ID
* @return 分配结果 主要是分配失败的群列表
@ -677,7 +681,7 @@ public interface WxCpExternalContactService {
* <p>
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_msg_template?access_token=ACCESS_TOKEN
* <p>
* 文档地址https://work.weixin.qq.com/api/doc/90000/90135/92135
* <a href="https://work.weixin.qq.com/api/doc/90000/90135/92135">文档地址</a>
*
* @param wxCpMsgTemplate the wx cp msg template
* @return the wx cp msg template add result
@ -696,7 +700,7 @@ public interface WxCpExternalContactService {
*
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/send_welcome_msg?access_token=ACCESS_TOKEN
*
* 文档地址https://work.weixin.qq.com/api/doc/90000/90135/92137
* <a href="https://work.weixin.qq.com/api/doc/90000/90135/92137">文档地址</a>
* </pre>
*
* @param msg .
@ -771,7 +775,7 @@ public interface WxCpExternalContactService {
/**
* <pre>
* 企业可通过此接口为指定成员的客户添加上由企业统一配置的标签
* https://work.weixin.qq.com/api/doc/90000/90135/92117
* <a href="https://work.weixin.qq.com/api/doc/90000/90135/92117">文档地址</a>
* </pre>
*
* @param userid the userid
@ -786,7 +790,7 @@ public interface WxCpExternalContactService {
/**
* <pre>
* 企业和第三方应用可通过该接口创建客户朋友圈的发表任务
* https://open.work.weixin.qq.com/api/doc/90000/90135/95094
* <a href="https://open.work.weixin.qq.com/api/doc/90000/90135/95094">文档地址</a>
* </pre>
*
* @param task the task
@ -798,7 +802,7 @@ public interface WxCpExternalContactService {
/**
* <pre>
* 由于发表任务的创建是异步执行的应用需要再调用该接口以获取创建的结果
* https://open.work.weixin.qq.com/api/doc/90000/90135/95094
* <a href="https://open.work.weixin.qq.com/api/doc/90000/90135/95094">文档地址</a>
* </pre>
*
* @param jobId 异步任务id最大长度为64字节由创建发表内容到客户朋友圈任务接口获取
@ -810,7 +814,7 @@ public interface WxCpExternalContactService {
/**
* <pre>
* 获取客户朋友圈全部的发表记录 获取企业全部的发表列表
* https://open.work.weixin.qq.com/api/doc/90000/90135/93333
* <a href="https://open.work.weixin.qq.com/api/doc/90000/90135/93333">文档地址</a>
* </pre>
*
* @param startTime 朋友圈记录开始时间Unix时间戳
@ -828,7 +832,7 @@ public interface WxCpExternalContactService {
/**
* <pre>
* 获取客户朋友圈全部的发表记录 获取客户朋友圈企业发表的列表
* https://open.work.weixin.qq.com/api/doc/90000/90135/93333
* <a href="https://open.work.weixin.qq.com/api/doc/90000/90135/93333">文档地址</a>
* </pre>
*
* @param momentId 朋友圈id,仅支持企业发表的朋友圈id
@ -843,7 +847,7 @@ public interface WxCpExternalContactService {
/**
* <pre>
* 获取客户朋友圈全部的发表记录 获取客户朋友圈发表时选择的可见范围
* https://open.work.weixin.qq.com/api/doc/90000/90135/93333
* <a href="https://open.work.weixin.qq.com/api/doc/90000/90135/93333">文档地址</a>
* </pre>
*
* @param momentId 朋友圈id
@ -860,7 +864,7 @@ public interface WxCpExternalContactService {
/**
* <pre>
* 获取客户朋友圈全部的发表记录 获取客户朋友圈发表后的可见客户列表
* https://open.work.weixin.qq.com/api/doc/90000/90135/93333
* <a href="https://open.work.weixin.qq.com/api/doc/90000/90135/93333">文档地址</a>
* </pre>
*
* @param momentId 朋友圈id
@ -877,7 +881,7 @@ public interface WxCpExternalContactService {
/**
* <pre>
* 获取客户朋友圈全部的发表记录 获取客户朋友圈的互动数据
* https://open.work.weixin.qq.com/api/doc/90000/90135/93333
* <a href="https://open.work.weixin.qq.com/api/doc/90000/90135/93333">文档地址</a>
* </pre>
*
* @param momentId 朋友圈id
@ -892,7 +896,7 @@ public interface WxCpExternalContactService {
/**
* <pre>
* 企业和第三方应用可通过此接口获取企业与成员的群发记录
* https://work.weixin.qq.com/api/doc/90000/90135/93338
* <a href="https://work.weixin.qq.com/api/doc/90000/90135/93338">文档地址</a>
* </pre>
*
* @param chatType 群发任务的类型默认为single表示发送给客户group表示发送给客户群
@ -911,7 +915,7 @@ public interface WxCpExternalContactService {
/**
* <pre>
* 企业和第三方应用可通过此接口获取企业与成员的群发记录
* https://work.weixin.qq.com/api/doc/90000/90135/93338#获取企业群发成员执行结果
* <a href="https://work.weixin.qq.com/api/doc/90000/90135/93338#获取企业群发成员执行结果">获取企业群发成员执行结果</a>
* </pre>
*
* @param msgid 群发消息的id通过获取群发记录列表接口返回
@ -926,7 +930,7 @@ public interface WxCpExternalContactService {
/**
* <pre>
* 企业跟第三方应用可通过该接口获取到创建企业群发的群发发送结果
* https://work.weixin.qq.com/api/doc/16251
* <a href="https://work.weixin.qq.com/api/doc/16251">文档</a>
* </pre>
*
* @param msgid 群发消息的id通过创建企业群发接口返回
@ -940,7 +944,7 @@ public interface WxCpExternalContactService {
/**
* <pre>
* 获取群发成员发送任务列表
* https://work.weixin.qq.com/api/doc/90000/90135/93338#获取群发成员发送任务列表
* <a href="https://work.weixin.qq.com/api/doc/90000/90135/93338#获取群发成员发送任务列表">获取群发成员发送任务列表</a>
* </pre>
*
* @param msgid 群发消息的id通过获取群发记录列表接口返回
@ -954,7 +958,7 @@ public interface WxCpExternalContactService {
/**
* <pre>
* 添加入群欢迎语素材
* https://open.work.weixin.qq.com/api/doc/90000/90135/92366#添加入群欢迎语素材
* <a href="https://open.work.weixin.qq.com/api/doc/90000/90135/92366#添加入群欢迎语素材">添加入群欢迎语素材</a>
* </pre>
*
* @param template 素材内容
@ -966,7 +970,7 @@ public interface WxCpExternalContactService {
/**
* <pre>
* 编辑入群欢迎语素材
* https://open.work.weixin.qq.com/api/doc/90000/90135/92366#编辑入群欢迎语素材
* <a href="https://open.work.weixin.qq.com/api/doc/90000/90135/92366#编辑入群欢迎语素材">编辑入群欢迎语素材</a>
* </pre>
*
* @param template the template
@ -978,7 +982,7 @@ public interface WxCpExternalContactService {
/**
* <pre>
* 获取入群欢迎语素材
* https://open.work.weixin.qq.com/api/doc/90000/90135/92366#获取入群欢迎语素材
* <a href="https://open.work.weixin.qq.com/api/doc/90000/90135/92366#获取入群欢迎语素材">获取入群欢迎语素材</a>
* </pre>
*
* @param templateId 群欢迎语的素材id
@ -991,7 +995,7 @@ public interface WxCpExternalContactService {
* <pre>
* 删除入群欢迎语素材
* 企业可通过此API删除入群欢迎语素材且仅能删除调用方自己创建的入群欢迎语素材
* https://open.work.weixin.qq.com/api/doc/90000/90135/92366#删除入群欢迎语素材
* <a href="https://open.work.weixin.qq.com/api/doc/90000/90135/92366#删除入群欢迎语素材">删除入群欢迎语素材</a>
* </pre>
*
* @param templateId 群欢迎语的素材id
@ -1004,7 +1008,7 @@ public interface WxCpExternalContactService {
/**
* <pre>
* 获取商品图册
* https://work.weixin.qq.com/api/doc/90000/90135/95096#获取商品图册列表
* <a href="https://work.weixin.qq.com/api/doc/90000/90135/95096#获取商品图册列表">获取商品图册列表</a>
* </pre>
*
* @param limit 返回的最大记录数整型最大值100默认值50超过最大值时取默认值
@ -1017,7 +1021,7 @@ public interface WxCpExternalContactService {
/**
* <pre>
* 获取商品图册
* https://work.weixin.qq.com/api/doc/90000/90135/95096#获取商品图册
* <a href="https://work.weixin.qq.com/api/doc/90000/90135/95096#获取商品图册">获取商品图册</a>
* </pre>
*
* @param productId 商品id
@ -1029,7 +1033,7 @@ public interface WxCpExternalContactService {
/**
* <pre>
* 上传附件资源
* https://open.work.weixin.qq.com/api/doc/90001/90143/95178
* <a href="https://open.work.weixin.qq.com/api/doc/90001/90143/95178">...</a>
* </pre>
*
* @param mediaType the media type
@ -1046,7 +1050,7 @@ public interface WxCpExternalContactService {
/**
* <pre>
* 上传附件资源
* https://open.work.weixin.qq.com/api/doc/90001/90143/95178
* <a href="https://open.work.weixin.qq.com/api/doc/90001/90143/95178">...</a>
* </pre>
*
* @param mediaType the media type
@ -1065,11 +1069,11 @@ public interface WxCpExternalContactService {
* 请求方式POST(HTTPS)
* 请求地址https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_intercept_rule?access_token=ACCESS_TOKEN
* <pre>
* @param ruleResp the rule resp
* @return the wx cp intercept rule result resp
* @param ruleAddRequest the rule add request
* @return 规则id
* @throws WxErrorException the wx error exception
*/
WxCpInterceptRuleResultResp addInterceptRule(WxCpInterceptRuleResp ruleResp) throws WxErrorException;
String addInterceptRule(WxCpInterceptRuleAddRequest ruleAddRequest) throws WxErrorException;
/**
* <pre>
@ -1078,24 +1082,22 @@ public interface WxCpExternalContactService {
* 请求方式POST(HTTPS)
* 请求地址https://qyapi.weixin.qq.com/cgi-bin/externalcontact/update_intercept_rule?access_token=ACCESS_TOKEN
* <pre>
* @param ruleResp the rule resp
* @return the wx cp intercept rule result resp
* @param interceptRule the rule
* @throws WxErrorException the wx error exception
*/
WxCpInterceptRuleResultResp updateInterceptRule(WxCpInterceptRuleResp ruleResp) throws WxErrorException;
void updateInterceptRule(WxCpInterceptRule interceptRule) throws WxErrorException;
/**
* <pre>
* 删除敏感词规则
* 企业和第三方应用可以通过此接口修改敏感词规则
* 请求方式POST(HTTPS)
* 请求地址https://qyapi.weixin.qq.com/cgi-bin/externalcontact/del_intercept_rule?access_token=ACCESS_TOKEN
* <a href="https://qyapi.weixin.qq.com/cgi-bin/externalcontact/del_intercept_rule?access_token=ACCESS_TOKEN">请求地址</a>
* <pre>
* @param rule_id 规则id
* @return the wx cp base resp
* @param ruleId 规则id
* @throws WxErrorException the wx error exception
*/
WxCpBaseResp delInterceptRule(String rule_id) throws WxErrorException;
void delInterceptRule(String ruleId) throws WxErrorException;
/**
* <pre>
@ -1104,8 +1106,7 @@ public interface WxCpExternalContactService {
* 请求方式POST(HTTPS)
* 请求地址
* <a href="https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_product_album?access_token=ACCESS_TOKEN">https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_product_album?access_token=ACCESS_TOKEN</a>
* 文档地址
* <a href="https://developer.work.weixin.qq.com/document/path/95096#%E5%88%9B%E5%BB%BA%E5%95%86%E5%93%81%E5%9B%BE%E5%86%8C">https://developer.work.weixin.qq.com/document/path/95096#%E5%88%9B%E5%BB%BA%E5%95%86%E5%93%81%E5%9B%BE%E5%86%8C</a>
* <a href="https://developer.work.weixin.qq.com/document/path/95096#%E5%88%9B%E5%BB%BA%E5%95%86%E5%93%81%E5%9B%BE%E5%86%8C">文档地址</a>
* <pre>
* @param wxCpProductAlbumInfo 商品图册信息
* @return 商品id string
@ -1120,8 +1121,7 @@ public interface WxCpExternalContactService {
* 请求方式POST(HTTPS)
* 请求地址
* <a href="https://qyapi.weixin.qq.com/cgi-bin/externalcontact/update_product_album?access_token=ACCESS_TOKEN">https://qyapi.weixin.qq.com/cgi-bin/externalcontact/update_product_album?access_token=ACCESS_TOKEN</a>
* 文档地址
* <a href="https://developer.work.weixin.qq.com/document/path/95096#%E7%BC%96%E8%BE%91%E5%95%86%E5%93%81%E5%9B%BE%E5%86%8C">https://developer.work.weixin.qq.com/document/path/95096#%E7%BC%96%E8%BE%91%E5%95%86%E5%93%81%E5%9B%BE%E5%86%8C</a>
* <a href="https://developer.work.weixin.qq.com/document/path/95096#%E7%BC%96%E8%BE%91%E5%95%86%E5%93%81%E5%9B%BE%E5%86%8C">文档地址</a>
* <pre>
* @param wxCpProductAlbumInfo 商品图册信息
* @throws WxErrorException the wx error exception
@ -1135,8 +1135,8 @@ public interface WxCpExternalContactService {
* 请求方式POST(HTTPS)
* 请求地址
* <a href="https://qyapi.weixin.qq.com/cgi-bin/externalcontact/delete_product_album?access_token=ACCESS_TOKEN">https://qyapi.weixin.qq.com/cgi-bin/externalcontact/delete_product_album?access_token=ACCESS_TOKEN</a>
* 文档地址
* <a href="https://developer.work.weixin.qq.com/document/path/95096#%E5%88%A0%E9%99%A4%E5%95%86%E5%93%81%E5%9B%BE%E5%86%8C">https://developer.work.weixin.qq.com/document/path/95096#%E5%88%A0%E9%99%A4%E5%95%86%E5%93%81%E5%9B%BE%E5%86%8C</a>
*
* <a href="https://developer.work.weixin.qq.com/document/path/95096#%E5%88%A0%E9%99%A4%E5%95%86%E5%93%81%E5%9B%BE%E5%86%8C">文档地址</a>
* <pre>
* @param productId 商品id
* @throws WxErrorException the wx error exception

View File

@ -10,12 +10,15 @@ import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.BeanUtils;
import me.chanjar.weixin.common.util.fs.FileUtils;
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.json.GsonHelper;
import me.chanjar.weixin.common.util.json.GsonParser;
import me.chanjar.weixin.cp.api.WxCpExternalContactService;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.bean.external.*;
import me.chanjar.weixin.cp.bean.external.contact.*;
import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRule;
import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRuleAddRequest;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
@ -46,9 +49,8 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_CONTACT_WAY);
String responseContent = this.mainService.post(url, info.getContactWay().toJson());
return WxCpContactWayResult.fromJson(responseContent);
return WxCpContactWayResult.fromJson(this.mainService.post(url, info.getContactWay().toJson()));
}
@Override
@ -57,8 +59,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("config_id", configId);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CONTACT_WAY);
String responseContent = this.mainService.post(url, json.toString());
return WxCpContactWayInfo.fromJson(responseContent);
return WxCpContactWayInfo.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -71,9 +72,8 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_CONTACT_WAY);
String responseContent = this.mainService.post(url, info.getContactWay().toJson());
return WxCpBaseResp.fromJson(responseContent);
return WxCpBaseResp.fromJson(this.mainService.post(url, info.getContactWay().toJson()));
}
@Override
@ -82,9 +82,8 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("config_id", configId);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(DEL_CONTACT_WAY);
String responseContent = this.mainService.post(url, json.toString());
return WxCpBaseResp.fromJson(responseContent);
return WxCpBaseResp.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -96,16 +95,14 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(CLOSE_TEMP_CHAT);
String responseContent = this.mainService.post(url, json.toString());
return WxCpBaseResp.fromJson(responseContent);
return WxCpBaseResp.fromJson(this.mainService.post(url, json.toString()));
}
@Override
public WxCpExternalContactInfo getExternalContact(String userId) throws WxErrorException {
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_EXTERNAL_CONTACT + userId);
String responseContent = this.mainService.get(url, null);
return WxCpExternalContactInfo.fromJson(responseContent);
return WxCpExternalContactInfo.fromJson(this.mainService.get(url, null));
}
@Override
@ -115,8 +112,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
params = params + "&cursor=" + cursor;
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CONTACT_DETAIL + params);
String responseContent = this.mainService.get(url, null);
return WxCpExternalContactInfo.fromJson(responseContent);
return WxCpExternalContactInfo.fromJson(this.mainService.get(url, null));
}
@Override
@ -125,8 +121,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("external_userid", externalUserId);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(CONVERT_TO_OPENID);
String responseContent = this.mainService.post(url, json.toString());
JsonObject tmpJson = GsonParser.parse(responseContent);
return tmpJson.get("openid").getAsString();
return GsonParser.parse(responseContent).get("openid").getAsString();
}
@Override
@ -138,8 +133,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UNIONID_TO_EXTERNAL_USERID);
String responseContent = this.mainService.post(url, json.toString());
JsonObject tmpJson = GsonParser.parse(responseContent);
return tmpJson.get("external_userid").getAsString();
return GsonParser.parse(responseContent).get("external_userid").getAsString();
}
@Override
@ -148,8 +142,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("external_userid", externalUserid);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(TO_SERVICE_EXTERNAL_USERID);
String responseContent = this.mainService.post(url, json.toString());
JsonObject tmpJson = GsonParser.parse(responseContent);
return tmpJson.get("external_userid").getAsString();
return GsonParser.parse(responseContent).get("external_userid").getAsString();
}
@Override
@ -159,9 +152,9 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("source_agentid", sourceAgentId);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(FROM_SERVICE_EXTERNAL_USERID);
String responseContent = this.mainService.post(url, json.toString());
JsonObject tmpJson = GsonParser.parse(responseContent);
return tmpJson.get("external_userid").getAsString();
return GsonParser.parse(responseContent).get("external_userid").getAsString();
}
@Override
public WxCpExternalUserIdList unionidToExternalUserid3rd(String unionid, String openid,
String corpid) throws WxErrorException {
@ -172,8 +165,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("corpid", corpid);
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UNIONID_TO_EXTERNAL_USERID_3RD);
String responseContent = this.mainService.post(url, json.toString());
return WxCpExternalUserIdList.fromJson(responseContent);
return WxCpExternalUserIdList.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -183,8 +175,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.add("external_userid_list", new Gson().toJsonTree(externalUserIdList).getAsJsonArray());
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_NEW_EXTERNAL_USERID);
String responseContent = this.mainService.post(url, json.toString());
return WxCpNewExternalUserIdList.fromJson(responseContent);
return WxCpNewExternalUserIdList.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -192,8 +183,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
JsonObject json = new JsonObject();
json.addProperty("corpid", corpid);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(FINISH_EXTERNAL_USERID_MIGRATION);
String responseContent = this.mainService.post(url, json.toString());
return WxCpBaseResp.fromJson(responseContent);
return WxCpBaseResp.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -202,19 +192,13 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("opengid", opengid);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(OPENID_TO_CHATID);
String responseContent = this.mainService.post(url, json.toString());
JsonObject tmpJson = GsonParser.parse(responseContent);
return tmpJson.get("chat_id").getAsString();
return GsonParser.parse(responseContent).get("chat_id").getAsString();
}
@Override
public WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList,
String cursor,
Integer limit)
public WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String cursor, Integer limit)
throws WxErrorException {
final String url =
this.mainService
.getWxCpConfigStorage()
.getApiUrl(GET_CONTACT_DETAIL_BATCH);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CONTACT_DETAIL_BATCH);
JsonObject json = new JsonObject();
json.add("userid_list", new Gson().toJsonTree(userIdList).getAsJsonArray());
if (StringUtils.isNotBlank(cursor)) {
@ -264,8 +248,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("cursor", StringUtils.isEmpty(cursor) ? "" : cursor);
json.addProperty("page_size", pageSize == null ? 1000 : pageSize);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(LIST_UNASSIGNED_CONTACT);
final String result = this.mainService.post(url, json.toString());
return WxCpUserExternalUnassignList.fromJson(result);
return WxCpUserExternalUnassignList.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -275,8 +258,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("handover_userid", handOverUserid);
json.addProperty("takeover_userid", takeOverUserid);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(TRANSFER_UNASSIGNED_CONTACT);
final String result = this.mainService.post(url, json.toString());
return WxCpBaseResp.fromJson(result);
return WxCpBaseResp.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -295,28 +277,27 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("handover_userid", handOverUserid);
json.addProperty("takeover_userid", takeOverUserid);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(TRANSFER_RESULT);
final String result = this.mainService.post(url, json.toString());
return WxCpUserTransferResultResp.fromJson(result);
return WxCpUserTransferResultResp.fromJson(this.mainService.post(url, json.toString()));
}
@Override
public WxCpUserTransferCustomerResp resignedTransferCustomer(WxCpUserTransferCustomerReq req) throws WxErrorException {
public WxCpUserTransferCustomerResp resignedTransferCustomer(WxCpUserTransferCustomerReq req)
throws WxErrorException {
BeanUtils.checkRequiredFields(req);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(RESIGNED_TRANSFER_CUSTOMER);
final String result = this.mainService.post(url, req.toJson());
return WxCpUserTransferCustomerResp.fromJson(result);
return WxCpUserTransferCustomerResp.fromJson(this.mainService.post(url, req.toJson()));
}
@Override
public WxCpUserTransferResultResp resignedTransferResult(String handOverUserid,
String takeOverUserid, String cursor) throws WxErrorException {
String takeOverUserid, String cursor)
throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("cursor", cursor);
json.addProperty("handover_userid", handOverUserid);
json.addProperty("takeover_userid", takeOverUserid);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(RESIGNED_TRANSFER_RESULT);
final String result = this.mainService.post(url, json.toString());
return WxCpUserTransferResultResp.fromJson(result);
return WxCpUserTransferResultResp.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -337,8 +318,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.add("owner_filter", ownerFilter);
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_CHAT_LIST);
final String result = this.mainService.post(url, json.toString());
return WxCpUserExternalGroupChatList.fromJson(result);
return WxCpUserExternalGroupChatList.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -355,8 +335,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.add("owner_filter", ownerFilter);
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_CHAT_LIST);
final String result = this.mainService.post(url, json.toString());
return WxCpUserExternalGroupChatList.fromJson(result);
return WxCpUserExternalGroupChatList.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -365,8 +344,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("chat_id", chatId);
json.addProperty("need_name", needName);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_CHAT_INFO);
final String result = this.mainService.post(url, json.toString());
return WxCpUserExternalGroupChatInfo.fromJson(result);
return WxCpUserExternalGroupChatInfo.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -377,8 +355,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
}
json.addProperty("new_owner", newOwner);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_CHAT_TRANSFER);
final String result = this.mainService.post(url, json.toString());
return WxCpUserExternalGroupChatTransferResp.fromJson(result);
return WxCpUserExternalGroupChatTransferResp.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -389,8 +366,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
}
json.addProperty("new_owner", newOwner);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_CHAT_ONJOB_TRANSFER);
final String result = this.mainService.post(url, json.toString());
return WxCpUserExternalGroupChatTransferResp.fromJson(result);
return WxCpUserExternalGroupChatTransferResp.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -408,8 +384,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
}
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(LIST_USER_BEHAVIOR_DATA);
final String result = this.mainService.post(url, json.toString());
return WxCpUserExternalUserBehaviorStatistic.fromJson(result);
return WxCpUserExternalUserBehaviorStatistic.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -433,15 +408,13 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.add("owner_filter", ownerFilter);
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(LIST_GROUP_CHAT_DATA);
final String result = this.mainService.post(url, json.toString());
return WxCpUserExternalGroupChatStatistic.fromJson(result);
return WxCpUserExternalGroupChatStatistic.fromJson(this.mainService.post(url, json.toString()));
}
@Override
public WxCpMsgTemplateAddResult addMsgTemplate(WxCpMsgTemplate wxCpMsgTemplate) throws WxErrorException {
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_MSG_TEMPLATE);
final String result = this.mainService.post(url, wxCpMsgTemplate.toJson());
return WxCpMsgTemplateAddResult.fromJson(result);
return WxCpMsgTemplateAddResult.fromJson(this.mainService.post(url, wxCpMsgTemplate.toJson()));
}
@Override
@ -457,8 +430,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.add("tag_id", new Gson().toJsonTree(tagId).getAsJsonArray());
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CORP_TAG_LIST);
final String result = this.mainService.post(url, json.toString());
return WxCpUserExternalTagGroupList.fromJson(result);
return WxCpUserExternalTagGroupList.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -471,16 +443,14 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.add("group_id", new Gson().toJsonTree(groupId).getAsJsonArray());
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CORP_TAG_LIST);
final String result = this.mainService.post(url, json.toString());
return WxCpUserExternalTagGroupList.fromJson(result);
return WxCpUserExternalTagGroupList.fromJson(this.mainService.post(url, json.toString()));
}
@Override
public WxCpUserExternalTagGroupInfo addCorpTag(WxCpUserExternalTagGroupInfo tagGroup) throws WxErrorException {
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_CORP_TAG);
final String result = this.mainService.post(url, tagGroup.getTagGroup().toJson());
return WxCpUserExternalTagGroupInfo.fromJson(result);
return WxCpUserExternalTagGroupInfo.fromJson(this.mainService.post(url, tagGroup.getTagGroup().toJson()));
}
@Override
@ -491,8 +461,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("name", name);
json.addProperty("order", order);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(EDIT_CORP_TAG);
final String result = this.mainService.post(url, json.toString());
return WxCpBaseResp.fromJson(result);
return WxCpBaseResp.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -506,14 +475,11 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(DEL_CORP_TAG);
final String result = this.mainService.post(url, json.toString());
return WxCpBaseResp.fromJson(result);
return WxCpBaseResp.fromJson(this.mainService.post(url, json.toString()));
}
@Override
public WxCpBaseResp markTag(String userid, String externalUserid, String[] addTag, String[] removeTag) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("userid", userid);
json.addProperty("external_userid", externalUserid);
@ -526,23 +492,20 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(MARK_TAG);
final String result = this.mainService.post(url, json.toString());
return WxCpBaseResp.fromJson(result);
return WxCpBaseResp.fromJson(this.mainService.post(url, json.toString()));
}
@Override
public WxCpAddMomentResult addMomentTask(WxCpAddMomentTask task) throws WxErrorException {
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_MOMENT_TASK);
final String result = this.mainService.post(url, task.toJson());
return WxCpAddMomentResult.fromJson(result);
return WxCpAddMomentResult.fromJson(this.mainService.post(url, task.toJson()));
}
@Override
public WxCpGetMomentTaskResult getMomentTaskResult(String jobId) throws WxErrorException {
String params = "&jobid=" + jobId;
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_MOMENT_TASK_RESULT);
final String result = this.mainService.get(url, params);
return WxCpGetMomentTaskResult.fromJson(result);
return WxCpGetMomentTaskResult.fromJson(this.mainService.get(url, params));
}
@Override
@ -564,8 +527,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("limit", limit);
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_MOMENT_LIST);
final String result = this.mainService.post(url, json.toString());
return WxCpGetMomentList.fromJson(result);
return WxCpGetMomentList.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -580,8 +542,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("limit", limit);
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_MOMENT_TASK);
final String result = this.mainService.post(url, json.toString());
return WxCpGetMomentTask.fromJson(result);
return WxCpGetMomentTask.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -597,8 +558,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("limit", limit);
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_MOMENT_CUSTOMER_LIST);
final String result = this.mainService.post(url, json.toString());
return WxCpGetMomentCustomerList.fromJson(result);
return WxCpGetMomentCustomerList.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -614,8 +574,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("limit", limit);
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_MOMENT_SEND_RESULT);
final String result = this.mainService.post(url, json.toString());
return WxCpGetMomentSendResult.fromJson(result);
return WxCpGetMomentSendResult.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -625,26 +584,9 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("moment_id", momentId);
json.addProperty("userid", userId);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_MOMENT_COMMENTS);
final String result = this.mainService.post(url, json.toString());
return WxCpGetMomentComments.fromJson(result);
return WxCpGetMomentComments.fromJson(this.mainService.post(url, json.toString()));
}
/**
* <pre>
* 企业和第三方应用可通过此接口获取企业与成员的群发记录
* https://work.weixin.qq.com/api/doc/90000/90135/93338
* </pre>
*
* @param chatType 群发任务的类型默认为single表示发送给客户group表示发送给客户群
* @param startTime 群发任务记录开始时间
* @param endTime 群发任务记录结束时间
* @param creator 群发任务创建人企业账号id
* @param filterType 创建人类型0企业发表 1个人发表 2所有包括个人创建以及企业创建默认情况下为所有类型
* @param limit 返回的最大记录数整型最大值100默认值50超过最大值时取默认值
* @param cursor 用于分页查询的游标字符串类型由上一次调用返回首次调用可不填
* @return wx cp base resp
* @throws WxErrorException the wx error exception
*/
@Override
public WxCpGroupMsgListResult getGroupMsgListV2(String chatType, Date startTime, Date endTime,
String creator, Integer filterType, Integer limit, String cursor) throws WxErrorException {
@ -658,23 +600,9 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("cursor", cursor);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_GROUP_MSG_LIST_V2);
final String result = this.mainService.post(url, json.toString());
return WxCpGroupMsgListResult.fromJson(result);
return WxCpGroupMsgListResult.fromJson(this.mainService.post(url, json.toString()));
}
/**
* <pre>
* 企业和第三方应用可通过此接口获取企业与成员的群发记录
* https://work.weixin.qq.com/api/doc/90000/90135/93338#获取企业群发成员执行结果
* </pre>
*
* @param msgid 群发消息的id通过获取群发记录列表接口返回
* @param userid 发送成员userid通过获取群发成员发送任务列表接口返回
* @param limit 返回的最大记录数整型最大值1000默认值500超过最大值时取默认值
* @param cursor 用于分页查询的游标字符串类型由上一次调用返回首次调用可不填
* @return wx cp base resp
* @throws WxErrorException the wx error exception
*/
@Override
public WxCpGroupMsgSendResult getGroupMsgSendResult(String msgid, String userid, Integer limit, String cursor) throws WxErrorException {
JsonObject json = new JsonObject();
@ -684,22 +612,9 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("cursor", cursor);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_GROUP_MSG_SEND_RESULT);
final String result = this.mainService.post(url, json.toString());
return WxCpGroupMsgSendResult.fromJson(result);
return WxCpGroupMsgSendResult.fromJson(this.mainService.post(url, json.toString()));
}
/**
* <pre>
* 企业跟第三方应用可通过该接口获取到创建企业群发的群发发送结果
* https://work.weixin.qq.com/api/doc/16251
* </pre>
*
* @param msgid 群发消息的id通过创建企业群发接口返回
* @param limit 返回的最大记录数整型最大值10000默认值10000
* @param cursor 用于分页查询的游标字符串类型由上一次调用返回首次调用可不填
* @return wx cp base resp
* @throws WxErrorException the wx error exception
*/
@Override
public WxCpGroupMsgResult getGroupMsgResult(String msgid, Integer limit, String cursor) throws WxErrorException {
JsonObject json = new JsonObject();
@ -708,100 +623,40 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("cursor", cursor);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_GROUP_MSG_RESULT);
final String result = this.mainService.post(url, json.toString());
return WxCpGroupMsgResult.fromJson(result);
return WxCpGroupMsgResult.fromJson(this.mainService.post(url, json.toString()));
}
/**
* <pre>
* 获取群发成员发送任务列表
* https://work.weixin.qq.com/api/doc/90000/90135/93338#获取群发成员发送任务列表
* </pre>
*
* @param msgid 群发消息的id通过获取群发记录列表接口返回
* @param limit 返回的最大记录数整型最大值1000默认值500超过最大值时取默认值
* @param cursor 用于分页查询的游标字符串类型由上一次调用返回首次调用可不填
* @return wx cp base resp
* @throws WxErrorException the wx error exception
*/
@Override
public WxCpGroupMsgTaskResult getGroupMsgTask(String msgid, Integer limit, String cursor) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("msgid", msgid);
json.addProperty("limit", limit);
json.addProperty("cursor", cursor);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_GROUP_MSG_TASK);
final String result = this.mainService.post(url, json.toString());
return WxCpGroupMsgTaskResult.fromJson(result);
return WxCpGroupMsgTaskResult.fromJson(this.mainService.post(url,
GsonHelper.buildJsonObject("msgid", msgid,
"limit", limit,
"cursor", cursor)));
}
/**
* <pre>
* 添加入群欢迎语素材
* https://open.work.weixin.qq.com/api/doc/90000/90135/92366#添加入群欢迎语素材
* </pre>
*
* @param template 素材内容
* @return template_id 欢迎语素材id
* @throws WxErrorException the wx error exception
*/
@Override
public String addGroupWelcomeTemplate(WxCpGroupWelcomeTemplateResult template) throws WxErrorException {
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_WELCOME_TEMPLATE_ADD);
final String responseContent = this.mainService.post(url, template.toJson());
JsonObject tmpJson = GsonParser.parse(responseContent);
return tmpJson.get("template_id").getAsString();
return GsonParser.parse(responseContent).get("template_id").getAsString();
}
/**
* <pre>
* 编辑入群欢迎语素材
* https://open.work.weixin.qq.com/api/doc/90000/90135/92366#编辑入群欢迎语素材
* </pre>
*
* @param template
* @return wx cp base resp
* @throws WxErrorException the wx error exception
*/
@Override
public WxCpBaseResp editGroupWelcomeTemplate(WxCpGroupWelcomeTemplateResult template) throws WxErrorException {
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_WELCOME_TEMPLATE_EDIT);
final String result = this.mainService.post(url, template.toJson());
return WxCpGroupWelcomeTemplateResult.fromJson(result);
return WxCpGroupWelcomeTemplateResult.fromJson(this.mainService.post(url, template.toJson()));
}
/**
* <pre>
* 获取入群欢迎语素材
* https://open.work.weixin.qq.com/api/doc/90000/90135/92366#获取入群欢迎语素材
* </pre>
*
* @param templateId 群欢迎语的素材id
* @return wx cp base resp
* @throws WxErrorException the wx error exception
*/
@Override
public WxCpGroupWelcomeTemplateResult getGroupWelcomeTemplate(String templateId) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("template_id", templateId);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_WELCOME_TEMPLATE_GET);
final String result = this.mainService.post(url, json.toString());
return WxCpGroupWelcomeTemplateResult.fromJson(result);
return WxCpGroupWelcomeTemplateResult.fromJson(this.mainService.post(url, json.toString()));
}
/**
* <pre>
* 删除入群欢迎语素材
* 企业可通过此API删除入群欢迎语素材且仅能删除调用方自己创建的入群欢迎语素材
* https://open.work.weixin.qq.com/api/doc/90000/90135/92366#删除入群欢迎语素材
* </pre>
*
* @param templateId 群欢迎语的素材id
* @param agentId
* @return wx cp base resp
* @throws WxErrorException the wx error exception
*/
@Override
public WxCpBaseResp delGroupWelcomeTemplate(String templateId, String agentId) throws WxErrorException {
JsonObject json = new JsonObject();
@ -810,48 +665,24 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
json.addProperty("agentid", agentId);
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_WELCOME_TEMPLATE_DEL);
final String result = this.mainService.post(url, json.toString());
return WxCpBaseResp.fromJson(result);
return WxCpBaseResp.fromJson(this.mainService.post(url, json.toString()));
}
/**
* <pre>
* 获取商品图册
* https://work.weixin.qq.com/api/doc/90000/90135/95096#获取商品图册列表
* </pre>
*
* @param limit 返回的最大记录数整型最大值100默认值50超过最大值时取默认值
* @param cursor 用于分页查询的游标字符串类型由上一次调用返回首次调用可不填
* @return wx cp base resp
* @throws WxErrorException the wx error exception
*/
@Override
public WxCpProductAlbumListResult getProductAlbumList(Integer limit, String cursor) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("limit", limit);
json.addProperty("cursor", cursor);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_PRODUCT_ALBUM_LIST);
final String result = this.mainService.post(url, json.toString());
return WxCpProductAlbumListResult.fromJson(result);
return WxCpProductAlbumListResult.fromJson(this.mainService.post(url, json.toString()));
}
/**
* <pre>
* 获取商品图册
* https://work.weixin.qq.com/api/doc/90000/90135/95096#获取商品图册
* </pre>
*
* @param productId 商品id
* @return wx cp base resp
* @throws WxErrorException the wx error exception
*/
@Override
public WxCpProductAlbumResult getProductAlbum(String productId) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("product_id", productId);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_PRODUCT_ALBUM);
final String result = this.mainService.post(url, json.toString());
return WxCpProductAlbumResult.fromJson(result);
return WxCpProductAlbumResult.fromJson(this.mainService.post(url, json.toString()));
}
@Override
@ -871,34 +702,29 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
}
@Override
public WxCpInterceptRuleResultResp addInterceptRule(WxCpInterceptRuleResp ruleResp) throws WxErrorException {
return WxCpInterceptRuleResultResp
.fromJson(this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(ADD_INTERCEPT_RULE),
ruleResp.toJson()));
public String addInterceptRule(WxCpInterceptRuleAddRequest ruleAddRequest) throws WxErrorException {
String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage()
.getApiUrl(ADD_INTERCEPT_RULE), ruleAddRequest);
return GsonParser.parse(responseContent).get("rule_id").getAsString();
}
@Override
public WxCpInterceptRuleResultResp updateInterceptRule(WxCpInterceptRuleResp ruleResp) throws WxErrorException {
return WxCpInterceptRuleResultResp
.fromJson(this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_INTERCEPT_RULE),
ruleResp.toJson()));
public void updateInterceptRule(WxCpInterceptRule interceptRule) throws WxErrorException {
this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_INTERCEPT_RULE),
interceptRule);
}
@Override
public WxCpBaseResp delInterceptRule(String rule_id) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("rule_id", rule_id);
return WxCpBaseResp
.fromJson(this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(DEL_INTERCEPT_RULE),
jsonObject));
public void delInterceptRule(String ruleId) throws WxErrorException {
this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(DEL_INTERCEPT_RULE),
GsonHelper.buildJsonObject("rule_id", ruleId));
}
@Override
public String addProductAlbum(WxCpProductAlbumInfo wxCpProductAlbumInfo) throws WxErrorException {
String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_PRODUCT_ALBUM);
String responseContent = this.mainService.post(url, wxCpProductAlbumInfo.toJson());
JsonObject tmpJson = GsonParser.parse(responseContent);
return tmpJson.get("product_id").getAsString();
return GsonParser.parse(responseContent).get("product_id").getAsString();
}
@Override
@ -921,9 +747,8 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
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);
return WxCpGroupJoinWayResult.fromJson(this.mainService.post(url, wxCpGroupJoinWayInfo.getJoinWay().toJson()));
}
@Override
@ -932,8 +757,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
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);
return WxCpBaseResp.fromJson(this.mainService.post(url, wxCpGroupJoinWayInfo.getJoinWay().toJson()));
}
@Override
@ -941,9 +765,8 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
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);
return WxCpGroupJoinWayInfo.fromJson(this.mainService.post(url, json));
}
@Override
@ -951,7 +774,6 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
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);
return WxCpBaseResp.fromJson(this.mainService.post(url, json));
}
}

View File

@ -0,0 +1,42 @@
package me.chanjar.weixin.cp.bean.external.interceptrule;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import java.io.Serializable;
import java.util.List;
/**
* The type Applicable range.
*
* @author didi
*/
@Data
public class ApplicableRange implements Serializable {
private static final long serialVersionUID = -2473660177998792887L;
@SerializedName("user_list")
private List<String> userList;
@SerializedName("department_list")
private List<Integer> departmentList;
/**
* From json applicable range.
*
* @param json the json
* @return the applicable range
*/
public static ApplicableRange fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, ApplicableRange.class);
}
/**
* To json string.
*
* @return the string
*/
public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}
}

View File

@ -0,0 +1,66 @@
package me.chanjar.weixin.cp.bean.external.interceptrule;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import me.chanjar.weixin.common.bean.ToJson;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import java.io.Serializable;
import java.util.List;
/**
* 敏感词规则修改接口请求和详情接口响应共用的实体类
*
* @author didi
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WxCpInterceptRule implements Serializable, ToJson {
private static final long serialVersionUID = 7161086545769110431L;
@SerializedName("rule_name")
private String ruleName;
@SerializedName("rule_id")
private String ruleId;
@SerializedName("word_list")
private List<String> wordList;
@SerializedName("extra_rule")
private ExtraRule extraRule;
@SerializedName("intercept_type")
private int interceptType;
@SerializedName("applicable_range")
private ApplicableRange applicableRange;
@Data
public static class ExtraRule implements Serializable {
private static final long serialVersionUID = -6377386837586111671L;
@SerializedName("semantics_list")
private List<Integer> semanticsList;
}
/**
* From json wx cp intercept rule resp.
*
* @param json the json
* @return the wx cp intercept rule resp
*/
public static WxCpInterceptRule fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpInterceptRule.class);
}
/**
* To json string.
*
* @return the string
*/
public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}
}

View File

@ -1,12 +1,14 @@
package me.chanjar.weixin.cp.bean.external;
package me.chanjar.weixin.cp.bean.external.interceptrule;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import me.chanjar.weixin.common.bean.ToJson;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import java.io.Serializable;
import java.util.List;
/**
@ -18,7 +20,8 @@ import java.util.List;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WxCpInterceptRuleResp {
public class WxCpInterceptRuleAddRequest implements Serializable, ToJson {
private static final long serialVersionUID = 7161086545769110431L;
@SerializedName("rule_name")
private String ruleName;
@ -33,44 +36,14 @@ public class WxCpInterceptRuleResp {
@SerializedName("applicable_range")
private ApplicableRange applicableRange;
/**
* The type Applicable range.
*/
@Data
public static class ApplicableRange {
@SerializedName("user_list")
private List<String> userList;
@SerializedName("department_list")
private List<Integer> departmentList;
/**
* From json applicable range.
*
* @param json the json
* @return the applicable range
*/
public static ApplicableRange fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, ApplicableRange.class);
}
/**
* To json string.
*
* @return the string
*/
public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}
}
/**
* From json wx cp intercept rule resp.
*
* @param json the json
* @return the wx cp intercept rule resp
*/
public static WxCpInterceptRuleResp fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpInterceptRuleResp.class);
public static WxCpInterceptRuleAddRequest fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpInterceptRuleAddRequest.class);
}
/**

View File

@ -1,4 +1,4 @@
package me.chanjar.weixin.cp.bean.external;
package me.chanjar.weixin.cp.bean.external.interceptrule;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
@ -15,7 +15,8 @@ import java.io.Serializable;
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class WxCpInterceptRuleResultResp extends WxCpBaseResp implements Serializable {
public class WxCpInterceptRuleAddResult extends WxCpBaseResp implements Serializable {
private static final long serialVersionUID = 8540187819417742703L;
@SerializedName("rule_id")
private String ruleId;
@ -26,8 +27,8 @@ public class WxCpInterceptRuleResultResp extends WxCpBaseResp implements Seriali
* @param json the json
* @return the wx cp intercept rule result resp
*/
public static WxCpInterceptRuleResultResp fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpInterceptRuleResultResp.class);
public static WxCpInterceptRuleAddResult fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpInterceptRuleAddResult.class);
}
public String toJson() {