mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-30 01:58:23 +08:00
🎨 #3395【企业微信】增加"模板卡片事件推送"事件的相关属性
This commit is contained in:
@ -187,6 +187,17 @@ public class WxCpXmlMessage implements Serializable {
|
|||||||
@XStreamConverter(value = XStreamCDataConverter.class)
|
@XStreamConverter(value = XStreamCDataConverter.class)
|
||||||
private String taskId;
|
private String taskId;
|
||||||
|
|
||||||
|
@XStreamAlias("CardType")
|
||||||
|
@XStreamConverter(value = XStreamCDataConverter.class)
|
||||||
|
private String cardType;
|
||||||
|
|
||||||
|
@XStreamAlias("ResponseCode")
|
||||||
|
@XStreamConverter(value = XStreamCDataConverter.class)
|
||||||
|
private String responseCode;
|
||||||
|
|
||||||
|
@XStreamAlias("SelectedItems")
|
||||||
|
private List<SelectedItem> selectedItems;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信客服
|
* 微信客服
|
||||||
* 调用拉取消息接口时,需要传此token,用于校验请求的合法性
|
* 调用拉取消息接口时,需要传此token,用于校验请求的合法性
|
||||||
@ -750,4 +761,21 @@ public class WxCpXmlMessage implements Serializable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type selected Items.
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@XStreamAlias("SelectedItem")
|
||||||
|
public static class SelectedItem implements Serializable {
|
||||||
|
private static final long serialVersionUID = 6319921121637597406L;
|
||||||
|
|
||||||
|
@XStreamAlias("QuestionKey")
|
||||||
|
@XStreamConverter(value = XStreamCDataConverter.class)
|
||||||
|
private String questionKey;
|
||||||
|
|
||||||
|
@XStreamAlias(value = "OptionIds")
|
||||||
|
private List<String> optionIds;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,6 +48,11 @@ public class WxCpConsts {
|
|||||||
*/
|
*/
|
||||||
public static final String CHANGE_CONTACT = "change_contact";
|
public static final String CHANGE_CONTACT = "change_contact";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业微信模板卡片事件推送
|
||||||
|
*/
|
||||||
|
public static final String TEMPLATE_CARD_EVENT = "template_card_event";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 点击菜单拉取消息的事件推送.
|
* 点击菜单拉取消息的事件推送.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -93,6 +93,11 @@ public class XStreamTransformer {
|
|||||||
xstream.processAnnotations(WxCpXmlMessage.SendPicsInfo.class);
|
xstream.processAnnotations(WxCpXmlMessage.SendPicsInfo.class);
|
||||||
xstream.processAnnotations(WxCpXmlMessage.SendPicsInfo.Item.class);
|
xstream.processAnnotations(WxCpXmlMessage.SendPicsInfo.Item.class);
|
||||||
xstream.processAnnotations(WxCpXmlMessage.SendLocationInfo.class);
|
xstream.processAnnotations(WxCpXmlMessage.SendLocationInfo.class);
|
||||||
|
xstream.processAnnotations(WxCpXmlMessage.SelectedItem.class);
|
||||||
|
// 显式允许 String 类
|
||||||
|
xstream.allowTypes(new Class[]{String.class});
|
||||||
|
// 模板卡片事件推送独属
|
||||||
|
xstream.alias("OptionId",String.class);
|
||||||
return xstream;
|
return xstream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -302,6 +302,46 @@ public class WxCpXmlMessageTest {
|
|||||||
System.out.println(XStreamTransformer.toXml(WxCpXmlMessage.class, wxCpXmlMessage));
|
System.out.println(XStreamTransformer.toXml(WxCpXmlMessage.class, wxCpXmlMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test template card event.
|
||||||
|
*/
|
||||||
|
public void testTemplateCardEvent() {
|
||||||
|
String xml = "<xml>\n" +
|
||||||
|
"<ToUserName><![CDATA[toUser]]></ToUserName>\n" +
|
||||||
|
"<FromUserName><![CDATA[FromUser]]></FromUserName>\n" +
|
||||||
|
"<CreateTime>123456789</CreateTime>\n" +
|
||||||
|
"<MsgType><![CDATA[event]]></MsgType>\n" +
|
||||||
|
"<Event><![CDATA[template_card_event]]></Event>\n" +
|
||||||
|
"<EventKey><![CDATA[key111]]></EventKey>\n" +
|
||||||
|
"<TaskId><![CDATA[taskid111]]></TaskId>\n" +
|
||||||
|
"<CardType><![CDATA[text_notice]]></CardType>\n" +
|
||||||
|
"<ResponseCode><![CDATA[ResponseCode]]></ResponseCode>\n" +
|
||||||
|
"<AgentID>1</AgentID>\n" +
|
||||||
|
"<SelectedItems>\n" +
|
||||||
|
" <SelectedItem>\n" +
|
||||||
|
" <QuestionKey><![CDATA[QuestionKey1]]></QuestionKey>\n" +
|
||||||
|
" <OptionIds>\n" +
|
||||||
|
" <OptionId><![CDATA[OptionId1]]></OptionId>\n" +
|
||||||
|
" <OptionId><![CDATA[OptionId2]]></OptionId>\n" +
|
||||||
|
" </OptionIds>\n" +
|
||||||
|
" </SelectedItem>\n" +
|
||||||
|
" <SelectedItem>\n" +
|
||||||
|
" <QuestionKey><![CDATA[QuestionKey2]]></QuestionKey>\n" +
|
||||||
|
" <OptionIds>\n" +
|
||||||
|
" <OptionId><![CDATA[OptionId3]]></OptionId>\n" +
|
||||||
|
" <OptionId><![CDATA[OptionId4]]></OptionId>\n" +
|
||||||
|
" </OptionIds>\n" +
|
||||||
|
" </SelectedItem>\n" +
|
||||||
|
"</SelectedItems>\n" +
|
||||||
|
"</xml>";
|
||||||
|
|
||||||
|
WxCpXmlMessage wxCpXmlMessage = WxCpXmlMessage.fromXml(xml);
|
||||||
|
assertThat(wxCpXmlMessage).isNotNull();
|
||||||
|
assertThat(wxCpXmlMessage.getSelectedItems()).isNotEmpty();
|
||||||
|
assertThat(wxCpXmlMessage.getSelectedItems().get(0).getQuestionKey()).isNotEmpty();
|
||||||
|
assertThat(wxCpXmlMessage.getSelectedItems().get(0).getOptionIds().get(0)).isNotEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test open approval change.
|
* Test open approval change.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user