1
0
mirror of synced 2025-12-29 06:37:58 +08:00

🆕 #3188 【视频号】实现视频号助手相关接口

This commit is contained in:
杨镇涛
2024-01-30 00:00:32 +08:00
committed by GitHub
parent 44ec8b2669
commit 0104af1534
31 changed files with 1870 additions and 1 deletions

View File

@@ -0,0 +1,65 @@
package me.chanjar.weixin.channel.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.channel.api.WxChannelService;
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
import me.chanjar.weixin.channel.bean.window.request.AddWindowProductRequest;
import me.chanjar.weixin.channel.bean.window.request.GetWindowProductListRequest;
import me.chanjar.weixin.channel.bean.window.request.WindowProductRequest;
import me.chanjar.weixin.channel.test.ApiTestModule;
import me.chanjar.weixin.common.error.WxErrorException;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
/**
* @author <a href="https://github.com/imyzt">imyzt</a>
*/
@Guice(modules = ApiTestModule.class)
public class WxAssistantServiceImplTest {
@Inject
private WxChannelService channelService;
@Test
public void testAddWindowProduct() throws WxErrorException {
AddWindowProductRequest req = new AddWindowProductRequest();
req.setProductId("123");
req.setAppid(channelService.getConfig().getAppid());
req.setIsHideForWindow(true);
WxChannelBaseResponse response = channelService.getAssistantService().addWindowProduct(req);
assertNotNull(response);
assertTrue(response.isSuccess());
}
@Test
public void testGetWindowProduct() throws WxErrorException {
WindowProductRequest req = new WindowProductRequest();
req.setProductId("123");
req.setAppid(channelService.getConfig().getAppid());
WxChannelBaseResponse response = channelService.getAssistantService().getWindowProduct(req);
assertNotNull(response);
assertTrue(response.isSuccess());
}
@Test
public void testGetWindowProductList() throws WxErrorException {
GetWindowProductListRequest req = new GetWindowProductListRequest();
req.setAppid(channelService.getConfig().getAppid());
WxChannelBaseResponse response = channelService.getAssistantService().getWindowProductList(req);
assertNotNull(response);
assertTrue(response.isSuccess());
}
@Test
public void testOffWindowProduct() throws WxErrorException {
WindowProductRequest req = new WindowProductRequest();
req.setProductId("123");
req.setAppid(channelService.getConfig().getAppid());
WxChannelBaseResponse response = channelService.getAssistantService().offWindowProduct(req);
assertNotNull(response);
assertTrue(response.isSuccess());
}
}

View File

@@ -0,0 +1,68 @@
package me.chanjar.weixin.channel.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.channel.api.WxChannelService;
import me.chanjar.weixin.channel.bean.lead.component.request.GetFinderLiveDataListRequest;
import me.chanjar.weixin.channel.bean.lead.component.request.GetFinderLiveLeadsDataRequest;
import me.chanjar.weixin.channel.bean.lead.component.response.FinderAttrResponse;
import me.chanjar.weixin.channel.bean.lead.component.response.GetFinderLiveDataListResponse;
import me.chanjar.weixin.channel.bean.lead.component.response.GetFinderLiveLeadsDataResponse;
import me.chanjar.weixin.channel.test.ApiTestModule;
import me.chanjar.weixin.common.error.WxErrorException;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Objects;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
/**
* @author <a href="https://github.com/imyzt">imyzt</a>
*/
@Guice(modules = ApiTestModule.class)
public class WxFinderLiveServiceImplTest {
@Inject
private WxChannelService channelService;
@Test
public void testGetFinderAttrByAppid() throws WxErrorException {
FinderAttrResponse response = channelService.getFinderLiveService().getFinderAttrByAppid();
System.out.println(response);
assertNotNull(response);
assertTrue(response.isSuccess());
}
@Test
public void testGetFinderLiveDataList() throws WxErrorException {
String lastBuffer = null;
for (; ; ) {
GetFinderLiveDataListRequest req = new GetFinderLiveDataListRequest();
req.setLastBuffer(lastBuffer);
GetFinderLiveDataListResponse response = channelService.getFinderLiveService().getFinderLiveDataList(req);
System.out.println(response);
assertNotNull(response);
assertTrue(response.isSuccess());
lastBuffer = response.getLastBuffer();
if (Objects.isNull(lastBuffer)) {
break;
}
}
}
@Test
public void testGetFinderLiveLeadsData() throws WxErrorException {
GetFinderLiveLeadsDataRequest req = new GetFinderLiveLeadsDataRequest();
req.setStartTime(Instant.now().minus(1, ChronoUnit.DAYS).getEpochSecond());
req.setEndTime(Instant.now().getEpochSecond());
GetFinderLiveLeadsDataResponse response = channelService.getFinderLiveService().getFinderLiveLeadsData(req);
assertNotNull(response);
assertTrue(response.isSuccess());
for (GetFinderLiveLeadsDataResponse.LeadCountItem item : response.getItems()) {
System.out.println(item.toString());
}
}
}

View File

@@ -0,0 +1,123 @@
package me.chanjar.weixin.channel.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.channel.api.WxChannelService;
import me.chanjar.weixin.channel.bean.lead.component.request.GetLeadInfoByComponentRequest;
import me.chanjar.weixin.channel.bean.lead.component.request.GetLeadsComponentIdRequest;
import me.chanjar.weixin.channel.bean.lead.component.request.GetLeadsComponentPromoteRecordRequest;
import me.chanjar.weixin.channel.bean.lead.component.request.GetLeadsInfoByRequestIdRequest;
import me.chanjar.weixin.channel.bean.lead.component.request.GetLeadsRequestIdRequest;
import me.chanjar.weixin.channel.bean.lead.component.response.GetLeadsComponentIdResponse;
import me.chanjar.weixin.channel.bean.lead.component.response.GetLeadsComponentPromoteRecordResponse;
import me.chanjar.weixin.channel.bean.lead.component.response.GetLeadsRequestIdResponse;
import me.chanjar.weixin.channel.bean.lead.component.response.LeadInfoResponse;
import me.chanjar.weixin.channel.test.ApiTestModule;
import me.chanjar.weixin.common.error.WxErrorException;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Objects;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
/**
* @author <a href="https://github.com/imyzt">imyzt</a>
*/
@Guice(modules = ApiTestModule.class)
public class WxLeadComponentServiceImplTest {
@Inject
private WxChannelService channelService;
@Test
public void testGetLeadsInfoByComponentId() throws WxErrorException {
String lastBuffer = null;
for (; ; ) {
GetLeadInfoByComponentRequest req = new GetLeadInfoByComponentRequest();
req.setStartTime(Instant.now().minus(1, ChronoUnit.DAYS).getEpochSecond());
req.setEndTime(Instant.now().getEpochSecond());
req.setLeadsComponentId("123");
req.setLastBuffer(lastBuffer);
LeadInfoResponse response = channelService.getLeadComponentService().getLeadsInfoByComponentId(req);
assertNotNull(response);
assertTrue(response.isSuccess());
lastBuffer = response.getLastBuffer();
if (Objects.isNull(lastBuffer)) {
break;
}
}
}
@Test
public void testGetLeadsInfoByRequestId() throws WxErrorException {
String lastBuffer = null;
for (; ; ) {
GetLeadsInfoByRequestIdRequest req = new GetLeadsInfoByRequestIdRequest();
req.setLastBuffer(lastBuffer);
req.setRequestId("123");
LeadInfoResponse response = channelService.getLeadComponentService().getLeadsInfoByRequestId(req);
assertNotNull(response);
assertTrue(response.isSuccess());
lastBuffer = response.getLastBuffer();
if (Objects.isNull(lastBuffer)) {
break;
}
}
}
@Test
public void testGetLeadsRequestId() throws WxErrorException {
String lastBuffer = null;
for (; ; ) {
GetLeadsRequestIdRequest req = new GetLeadsRequestIdRequest();
req.setLastBuffer(lastBuffer);
req.setLeadsComponentId("123");
GetLeadsRequestIdResponse response = channelService.getLeadComponentService().getLeadsRequestId(req);
assertNotNull(response);
assertTrue(response.isSuccess());
lastBuffer = response.getLastBuffer();
if (Objects.isNull(lastBuffer)) {
break;
}
}
}
@Test
public void testGetLeadsComponentPromoteRecord() throws WxErrorException {
String lastBuffer = null;
for (; ; ) {
GetLeadsComponentPromoteRecordRequest req = new GetLeadsComponentPromoteRecordRequest();
req.setStartTime(Instant.now().minus(1, ChronoUnit.DAYS).getEpochSecond());
req.setEndTime(Instant.now().getEpochSecond());
req.setLeadsComponentId("123");
req.setLastBuffer(lastBuffer);
GetLeadsComponentPromoteRecordResponse response = channelService.getLeadComponentService().getLeadsComponentPromoteRecord(req);
assertNotNull(response);
assertTrue(response.isSuccess());
lastBuffer = response.getLastBuffer();
if (Objects.isNull(lastBuffer)) {
break;
}
}
}
@Test
public void testGetLeadsComponentId() throws WxErrorException {
String lastBuffer = null;
for (; ; ) {
GetLeadsComponentIdRequest req = new GetLeadsComponentIdRequest();
req.setLastBuffer(lastBuffer);
GetLeadsComponentIdResponse response = channelService.getLeadComponentService().getLeadsComponentId(req);
System.out.println(response);
assertNotNull(response);
assertTrue(response.isSuccess());
lastBuffer = response.getLastBuffer();
if (Objects.isNull(lastBuffer)) {
break;
}
}
}
}