weixin4j-qy:新增获取客服列表接口

This commit is contained in:
jinyu 2016-01-23 02:10:02 +08:00
parent 1ea6d9872c
commit 9a2a91b78d
9 changed files with 118 additions and 46 deletions

View File

@ -616,3 +616,7 @@
+ weixin4j-mp:新增获取模板和删除模板接口
+ weixin4j-mp:新增自定义个性化菜单语言信息匹配项
* 2016-01-23
+ weixin4j-qy:新增获取客服列表接口

View File

@ -164,3 +164,7 @@
* 2015-12-31
+ version upgrade to 1.6.6
* 2016-01-23
+ 新增获取客服列表接口

View File

@ -44,6 +44,7 @@ import com.foxinmy.weixin4j.qy.token.WeixinTicketCreator;
import com.foxinmy.weixin4j.qy.token.WeixinTokenCreator;
import com.foxinmy.weixin4j.qy.type.ChatType;
import com.foxinmy.weixin4j.qy.type.InviteType;
import com.foxinmy.weixin4j.qy.type.KfType;
import com.foxinmy.weixin4j.qy.type.UserStatus;
import com.foxinmy.weixin4j.token.TokenHolder;
import com.foxinmy.weixin4j.token.TokenStorager;
@ -242,6 +243,22 @@ public class WeixinProxy {
return notifyApi.sendCustomeMessage(message);
}
/**
* 获取客服列表
*
* @param kfType
* 客服类型 为空时返回全部类型的客服
* @return 第一个元素为内部客服(internal),第二个参数为外部客服(external)
* @see com.foxinmy.weixin4j.qy.api.NotifyApi
* @see com.foxinmy.weixin4j.qy.model.IdParameter
* @see <a
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E4%BC%81%E4%B8%9A%E5%AE%A2%E6%9C%8D%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E">客服列表</a>
* @throws WeixinException
*/
public IdParameter[] getKfList(KfType kfType) throws WeixinException {
return notifyApi.getKfList(kfType);
}
/**
* 自定义菜单(管理员须拥有应用的管理权限 并且应用必须设置在回调模式)
*

View File

@ -10,6 +10,8 @@ import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
import com.foxinmy.weixin4j.model.Token;
import com.foxinmy.weixin4j.qy.message.CustomeMessage;
import com.foxinmy.weixin4j.qy.message.NotifyMessage;
import com.foxinmy.weixin4j.qy.model.IdParameter;
import com.foxinmy.weixin4j.qy.type.KfType;
import com.foxinmy.weixin4j.token.TokenHolder;
import com.foxinmy.weixin4j.tuple.NotifyTuple;
@ -119,4 +121,31 @@ public class NotifyApi extends QyApi {
obj.toJSONString());
return response.getAsJsonResult();
}
/**
* 获取客服列表
*
* @param kfType
* 客服类型 为空时返回全部类型的客服
* @return 第一个元素为内部客服(internal),第二个参数为外部客服(external)
* @see com.foxinmy.weixin4j.qy.model.IdParameter
* @see <a
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E4%BC%81%E4%B8%9A%E5%AE%A2%E6%9C%8D%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E">客服列表</a>
* @throws WeixinException
*/
public IdParameter[] getKfList(KfType kfType) throws WeixinException {
String message_kf_list_uri = getRequestUri("message_kf_list_uri");
if (kfType != null) {
message_kf_list_uri += "&type=" + kfType.name();
}
Token token = tokenHolder.getToken();
WeixinResponse response = weixinExecutor.get(String.format(
message_kf_list_uri, token.getAccessToken()));
JSONObject obj = response.getAsJson();
return new IdParameter[] {
obj.containsKey("internal") ? obj.getObject("internal",
IdParameter.class) : null,
obj.containsKey("external") ? obj.getObject("external",
IdParameter.class) : null };
}
}

View File

@ -61,6 +61,8 @@ menu_get_uri={api_base_url}/menu/get?access_token=%s&agentid=%d
message_send_uri={api_base_url}/message/send?access_token=%s
# \u53d1\u9001\u5ba2\u670d\u6d88\u606f
message_kf_send_uri={api_base_url}/kf/send?access_token=%s
# \u83b7\u53d6\u5ba2\u670d\u5217\u8868
message_kf_list_uri={api_base_url}/kf/list?access_token=%s
# \u83b7\u53d6\u5fae\u4fe1IP\u5730\u5740
getcallbackip_uri={api_base_url}/getcallbackip?access_token=%s
# \u83b7\u53d6\u4f01\u4e1a\u53f7\u5e94\u7528\u4fe1\u606f

View File

@ -37,13 +37,13 @@ public class JSSDKContactConfigurator {
}
/**
* 可选范围部门ID列表(如果departmentIds为0则表示显示管理组下所有部门)
* 可选范围部门ID列表(如果partyIds为0则表示显示管理组下所有部门)
*
* @param departmentIds
* @return
*/
public JSSDKContactConfigurator departmentIds(Integer... departmentIds) {
contactParameter.putDepartmentIds(departmentIds);
public JSSDKContactConfigurator partyIds(Integer... partyIds) {
contactParameter.putPartyIds(partyIds);
return this;
}

View File

@ -65,8 +65,8 @@ public class JSSDKContactParameter extends IdParameter {
this.limitTypes = limitTypes;
}
public void putLimitType(String type) {
this.limitTypes.add(type);
public void putLimitType(String... limitTypes) {
this.limitTypes.addAll(Arrays.asList(limitTypes));
}
public List<String> getSelectedUserIds() {

View File

@ -7,6 +7,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.util.StringUtil;
/**
@ -24,13 +25,16 @@ public class IdParameter implements Serializable {
private static final char SEPARATOR = '|';
@JSONField(name = "user")
private List<String> userIds;
private List<Integer> departmentIds;
@JSONField(name = "party")
private List<Integer> partyIds;
@JSONField(name = "tag")
private List<Integer> tagIds;
public IdParameter() {
this.userIds = new ArrayList<String>();
this.departmentIds = new ArrayList<Integer>();
this.partyIds = new ArrayList<Integer>();
this.tagIds = new ArrayList<Integer>();
}
@ -45,36 +49,14 @@ public class IdParameter implements Serializable {
return this;
}
/**
* 设置成员ID列表最多支持1000个
*
* @param userIds
* @return
*/
public IdParameter setUserIds(List<String> userIds) {
this.userIds = userIds;
return this;
}
/**
* 新增部门ID列表最多支持100个
*
* @param departmentIds
* @param partyIds
* @return
*/
public IdParameter putDepartmentIds(Integer... departmentIds) {
this.departmentIds.addAll(Arrays.asList(departmentIds));
return this;
}
/**
* 设置部门ID列表最多支持100个
*
* @param departmentIds
* @return
*/
public IdParameter setDepartmentIds(List<Integer> departmentIds) {
this.departmentIds = departmentIds;
public IdParameter putPartyIds(Integer... partyIds) {
this.partyIds.addAll(Arrays.asList(partyIds));
return this;
}
@ -89,19 +71,32 @@ public class IdParameter implements Serializable {
return this;
}
/**
* 设置标签ID列表
*
* @param tagIds
* @return
*/
public IdParameter setTagIds(List<Integer> tagIds) {
public List<String> getUserIds() {
return userIds;
}
public List<Integer> getPartyIds() {
return partyIds;
}
public List<Integer> getTagIds() {
return tagIds;
}
public void setUserIds(List<String> userIds) {
this.userIds = userIds;
}
public void setPartyIds(List<Integer> partyIds) {
this.partyIds = partyIds;
}
public void setTagIds(List<Integer> tagIds) {
this.tagIds = tagIds;
return this;
}
/**
* 目标参数
* 生成某些接口需要的目标参数 如发送客服消息接口
*
* @return
*/
@ -110,8 +105,8 @@ public class IdParameter implements Serializable {
if (userIds != null && !userIds.isEmpty()) {
parameterMap.put("touser", StringUtil.join(userIds, SEPARATOR));
}
if (departmentIds != null && !departmentIds.isEmpty()) {
parameterMap.put("toparty", StringUtil.join(departmentIds, SEPARATOR));
if (partyIds != null && !partyIds.isEmpty()) {
parameterMap.put("toparty", StringUtil.join(partyIds, SEPARATOR));
}
if (tagIds != null && !tagIds.isEmpty()) {
parameterMap.put("totag", StringUtil.join(tagIds, SEPARATOR));
@ -121,7 +116,7 @@ public class IdParameter implements Serializable {
@Override
public String toString() {
return "IdParameter [userIds=" + userIds + ", departmentIds="
+ departmentIds + ", tagIds=" + tagIds + "]";
return "IdParameter [userIds=" + userIds + ", partyIds=" + partyIds
+ ", tagIds=" + tagIds + "]";
}
}

View File

@ -0,0 +1,21 @@
package com.foxinmy.weixin4j.qy.type;
/**
* 客服类型
*
* @className KfType
* @author jy
* @date 2016年1月23日
* @since JDK 1.7
* @see
*/
public enum KfType {
/**
* 内部客服
*/
internal,
/**
* 外部客服
*/
external
}