Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) add msg template api for external contacts #1668

Merged
merged 1 commit into from
Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public interface WxCpExternalContactService {

/**
* 企业和第三方可通过此接口,获取所有离职成员的客户列表,并可进一步调用离职成员的外部联系人再分配接口将这些客户重新分配给其他企业成员。
*
* @param page
* @param pageSize
* @return
Expand All @@ -97,22 +98,24 @@ public interface WxCpExternalContactService {

/**
* 企业可通过此接口,将已离职成员的外部联系人分配给另一个成员接替联系。
*
* @param externalUserid
* @param handOverUserid
* @param takeOverUserid
* @return
* @throws WxErrorException
*/
WxCpBaseResp transferExternalContact(String externalUserid,String handOverUserid,String takeOverUserid)throws WxErrorException;
WxCpBaseResp transferExternalContact(String externalUserid, String handOverUserid, String takeOverUserid) throws WxErrorException;

/** <pre>
* 该接口用于获取配置过客户群管理的客户群列表。
* 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。
* 暂不支持第三方调用。
* 微信文档:https://work.weixin.qq.com/api/doc/90000/90135/92119
* </pre>
*/
WxCpUserExternalGroupChatList listGroupChat(Integer pageIndex,Integer pageSize,int status,String[] userIds,String[] partyIds) throws WxErrorException;
/**
* <pre>
* 该接口用于获取配置过客户群管理的客户群列表。
* 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。
* 暂不支持第三方调用。
* 微信文档:https://work.weixin.qq.com/api/doc/90000/90135/92119
* </pre>
*/
WxCpUserExternalGroupChatList listGroupChat(Integer pageIndex, Integer pageSize, int status, String[] userIds, String[] partyIds) throws WxErrorException;

/**
* <pre>
Expand All @@ -135,6 +138,7 @@ public interface WxCpExternalContactService {
* 第三方应用需拥有“企业客户”权限。
* 第三方/自建应用调用时传入的userid和partyid要在应用的可见范围内;
* </pre>
*
* @param startTime
* @param endTime
* @param userIds
Expand All @@ -150,6 +154,7 @@ public interface WxCpExternalContactService {
* 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。
* 暂不支持第三方调用。
* </pre>
*
* @param startTime
* @param orderBy
* @param orderAsc
Expand All @@ -160,5 +165,7 @@ public interface WxCpExternalContactService {
* @return
* @throws WxErrorException
*/
WxCpUserExternalGroupChatStatistic getGroupChatStatistic(Date startTime,Integer orderBy,Integer orderAsc,Integer pageIndex,Integer pageSize, String[] userIds, String[] partyIds) throws WxErrorException;
WxCpUserExternalGroupChatStatistic getGroupChatStatistic(Date startTime, Integer orderBy, Integer orderAsc, Integer pageIndex, Integer pageSize, String[] userIds, String[] partyIds) throws WxErrorException;

WxCpMsgTemplateAddResult addMsgTemplate(WxCpMsgTemplate wxCpMsgTemplate) throws WxErrorException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,11 @@ public WxCpUserExternalGroupChatStatistic getGroupChatStatistic(Date startTime,
final String result = this.mainService.post(url, json.toString());
return WxCpUserExternalGroupChatStatistic.fromJson(result);
}

@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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package me.chanjar.weixin.cp.bean;

import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;

import java.io.Serializable;
import java.util.List;

/**
* 企业群发消息任务
* <p>
* Created by songfan on 2020/7/14.
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WxCpMsgTemplate implements Serializable {
private static final long serialVersionUID = 3172331565173474358L;

@SerializedName("chat_type")
private String chatType;

@SerializedName("external_userid")
private List<String> externalUserid;

private String sender;

private Text text;

private Image image;

private Link link;

private Miniprogram miniprogram;

public static WxCpMsgTemplate fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpMsgTemplate.class);
}

public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}

@Data
public class Text {
private String content;
}

@Data
public class Image {

@SerializedName("media_id")
private String mediaId;

@SerializedName("pic_url")
private String picUrl;
}

@Data
public class Link {
private String title;
@SerializedName("picurl")
private String picUrl;
private String desc;
private String url;
}

@Data
public class Miniprogram {
private String title;
@SerializedName("pic_media_id")
private String picMediaId;
private String appid;
private String page;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package me.chanjar.weixin.cp.bean;

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;

/**
* Created by songfan on 2020/7/14.
*/
@Data
public class WxCpMsgTemplateAddResult implements Serializable {
private static final long serialVersionUID = -5166048319463473188L;

@SerializedName("errcode")
private Integer errCode;

@SerializedName("errmsg")
private String errMsg;

@SerializedName("fail_list")
private List<String> failList;

@SerializedName("msgid")
private String msgId;

public static WxCpMsgTemplateAddResult fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpMsgTemplateAddResult.class);
}

public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,6 @@ public static class ExternalContact {
public static final String GROUP_CHAT_INFO = "/cgi-bin/externalcontact/groupchat/get";
public static final String LIST_USER_BEHAVIOR_DATA = "/cgi-bin/externalcontact/get_user_behavior_data";
public static final String LIST_GROUP_CHAT_DATA = "/cgi-bin/externalcontact/groupchat/statistic";
public static final String ADD_MSG_TEMPLATE = "/cgi-bin/externalcontact/add_msg_template";
}
}