mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-06-28 13:16:19 +08:00
🆕 #3488【企业微信】增加获取企业已配置的「联系我」列表的接口
This commit is contained in:
parent
3e48dc7f83
commit
783c89523d
@ -59,6 +59,25 @@ public interface WxCpExternalContactService {
|
|||||||
*/
|
*/
|
||||||
WxCpContactWayInfo getContactWay(String configId) throws WxErrorException;
|
WxCpContactWayInfo getContactWay(String configId) throws WxErrorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取企业已配置的「联系我」列表
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* 获取企业配置的「联系我」二维码和「联系我」小程序插件列表。不包含临时会话。
|
||||||
|
* 注意,<b>该接口仅可获取2021年7月10日以后创建的「联系我」</b>
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* 文档地址: <a href="https://developer.work.weixin.qq.com/document/path/92228#%E8%8E%B7%E5%8F%96%E4%BC%81%E4%B8%9A%E5%B7%B2%E9%85%8D%E7%BD%AE%E7%9A%84%E3%80%8C%E8%81%94%E7%B3%BB%E6%88%91%E3%80%8D%E5%88%97%E8%A1%A8">获取企业已配置的「联系我」列表</a>
|
||||||
|
*
|
||||||
|
* @param startTime 「联系我」创建起始时间戳, 默认为90天前
|
||||||
|
* @param endTime 「联系我」创建结束时间戳, 默认为当前时间
|
||||||
|
* @param cursor 分页查询使用的游标,为上次请求返回的 next_cursor
|
||||||
|
* @param limit 每次查询的分页大小,默认为100条,最多支持1000条
|
||||||
|
* @return contact way configId
|
||||||
|
* @throws WxErrorException the wx error exception
|
||||||
|
*/
|
||||||
|
WxCpContactWayList listContactWay(Long startTime, Long endTime, String cursor, Long limit) throws WxErrorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新企业已配置的「联系我」方式
|
* 更新企业已配置的「联系我」方式
|
||||||
*
|
*
|
||||||
|
@ -65,6 +65,17 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
|
|||||||
return WxCpContactWayInfo.fromJson(this.mainService.post(url, json.toString()));
|
return WxCpContactWayInfo.fromJson(this.mainService.post(url, json.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WxCpContactWayList listContactWay(Long startTime, Long endTime, String cursor, Long limit) throws WxErrorException {
|
||||||
|
JsonObject json = new JsonObject();
|
||||||
|
json.addProperty("start_time", startTime);
|
||||||
|
json.addProperty("end_time", endTime);
|
||||||
|
json.addProperty("cursor", cursor);
|
||||||
|
json.addProperty("limit", limit);
|
||||||
|
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(LIST_CONTACT_WAY);
|
||||||
|
return WxCpContactWayList.fromJson(this.mainService.post(url, json.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxCpBaseResp updateContactWay(WxCpContactWayInfo info) throws WxErrorException {
|
public WxCpBaseResp updateContactWay(WxCpContactWayInfo info) throws WxErrorException {
|
||||||
if (StringUtils.isBlank(info.getContactWay().getConfigId())) {
|
if (StringUtils.isBlank(info.getContactWay().getConfigId())) {
|
||||||
|
63
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpContactWayList.java
vendored
Normal file
63
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpContactWayList.java
vendored
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
package me.chanjar.weixin.cp.bean.external;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||||
|
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 「联系我」方式 列表返回对象
|
||||||
|
*
|
||||||
|
* @author <a href="https://github.com/imyzt">imyzt</a>
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class WxCpContactWayList extends WxCpBaseResp implements Serializable {
|
||||||
|
private static final long serialVersionUID = -8697184659526210472L;
|
||||||
|
|
||||||
|
@SerializedName("contact_way")
|
||||||
|
private List<ContactWay> contactWay;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Contact way.
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public static class ContactWay implements Serializable {
|
||||||
|
private static final long serialVersionUID = -8697184659526210472L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 联系方式的配置id
|
||||||
|
*/
|
||||||
|
@SerializedName("config_id")
|
||||||
|
private String configId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From json wx cp contact way list.
|
||||||
|
*
|
||||||
|
* @param json the json
|
||||||
|
* @return the wx cp contact way list
|
||||||
|
*/
|
||||||
|
public static WxCpContactWayList fromJson(String json) {
|
||||||
|
return WxCpGsonBuilder.create().fromJson(json, WxCpContactWayList.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To json string.
|
||||||
|
*
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
public String toJson() {
|
||||||
|
return WxCpGsonBuilder.create().toJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1085,6 +1085,10 @@ public interface WxCpApiPathConsts {
|
|||||||
* The constant GET_CONTACT_WAY.
|
* The constant GET_CONTACT_WAY.
|
||||||
*/
|
*/
|
||||||
String GET_CONTACT_WAY = "/cgi-bin/externalcontact/get_contact_way";
|
String GET_CONTACT_WAY = "/cgi-bin/externalcontact/get_contact_way";
|
||||||
|
/**
|
||||||
|
* The constant LIST_CONTACT_WAY.
|
||||||
|
*/
|
||||||
|
String LIST_CONTACT_WAY = "/cgi-bin/externalcontact/list_contact_way";
|
||||||
/**
|
/**
|
||||||
* The constant UPDATE_CONTACT_WAY.
|
* The constant UPDATE_CONTACT_WAY.
|
||||||
*/
|
*/
|
||||||
|
@ -4,6 +4,9 @@ import static org.testng.Assert.assertNotNull;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneOffset;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -90,6 +93,20 @@ public class WxCpExternalContactServiceImplTest {
|
|||||||
assertNotNull(contactWayInfo);
|
assertNotNull(contactWayInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test list contact way.
|
||||||
|
*
|
||||||
|
* @throws WxErrorException the wx error exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testListContactWay() throws WxErrorException {
|
||||||
|
long startTime = LocalDateTime.now().minusDays(1).toEpochSecond(ZoneOffset.of("+8"));
|
||||||
|
long endTime = LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8"));
|
||||||
|
WxCpContactWayList wxCpContactWayList = this.wxCpService.getExternalContactService().listContactWay(startTime, endTime, null, 100L);
|
||||||
|
System.out.println(wxCpContactWayList.toJson());
|
||||||
|
assertNotNull(wxCpContactWayList);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test update contact way.
|
* Test update contact way.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user