1
0
mirror of synced 2025-12-23 10:39:27 +08:00

🎨 【企业微信】添加AttachmentBuilder,可以更方便的创建新客户欢迎语的附件信息

This commit is contained in:
codecrab
2023-03-29 16:19:13 +08:00
committed by GitHub
parent 722c2cfe2b
commit 6e96d7cf55
9 changed files with 95 additions and 6 deletions

View File

@@ -10,6 +10,7 @@ import me.chanjar.weixin.cp.bean.external.*;
import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactBatchInfo;
import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo;
import me.chanjar.weixin.cp.bean.external.msg.Attachment;
import me.chanjar.weixin.cp.bean.external.msg.AttachmentBuilder;
import me.chanjar.weixin.cp.bean.external.msg.Image;
import me.chanjar.weixin.cp.bean.external.msg.Video;
import org.apache.commons.lang3.time.DateFormatUtils;
@@ -17,7 +18,10 @@ import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import org.testng.collections.CollectionUtils;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import static org.testng.Assert.assertNotNull;
@@ -419,6 +423,7 @@ public class WxCpExternalContactServiceImplTest {
System.out.println(result);
assertNotNull(result);
}
/**
* Test get user behavior statistic.
*/
@@ -466,6 +471,33 @@ public class WxCpExternalContactServiceImplTest {
.build());
}
/**
* Test send welcome msg. use AttachmentBuilder
*
* @throws WxErrorException the wx error exception
*/
@Test
public void testSendWelcomeMsg2() throws WxErrorException {
Attachment imageAttachment = AttachmentBuilder.imageBuilder().mediaId("123123").build();
Attachment videoAttachment = AttachmentBuilder.videoBuilder().mediaId("video_media_id").build();
Attachment miniProgramAttachment = AttachmentBuilder.miniProgramBuilder()
.title("title")
.picMediaId("123123123")
.appId("wxcxxxxxxxxxxx")
.page("https://")
.build();
List<Attachment> attachments = new ArrayList<>();
attachments.add(imageAttachment);
attachments.add(videoAttachment);
attachments.add(miniProgramAttachment);
this.wxCpService.getExternalContactService().sendWelcomeMsg(WxCpWelcomeMsg.builder()
.welcomeCode("abc")
.attachments(attachments)
.build());
}
/**
* Test update remark.
*