package com.qikemi.wechat.api.service;

import org.apache.log4j.Logger;

import com.qikemi.packages.xmlJsonAndJavaBean.JavaBean2Xml;
import com.qikemi.wechat.api.constant.WechatReqMsgTypeConstant;
import com.qikemi.wechat.api.entity.message.MsgTypeBean;
import com.qikemi.wechat.api.entity.message.response.RespImageMsg;
import com.qikemi.wechat.api.entity.message.response.RespTextMsg;
import com.qikemi.wechat.api.entity.message.response.baseBean.ImageBean;

/**
 * Response Convert 2 XML 
 * Create Date: 2014年10月12日 下午9:00:55
 * Author XieXianbin<a.b@hotmail.com>
 * Source Repositories Address: <https://github.com/qikemi/open-wechat-sdk>
 */
public class ResponseConvert2XMLService {
	
	@SuppressWarnings("unused")
	private static Logger logger = Logger.getLogger(ResponseConvert2XMLService.class);

	public ResponseConvert2XMLService() {
		super();
	}

	/**
	 * get Text Message xml 
	 * @param reqTextMessage
	 * @param content
	 * @return
	 */
	public String getTextMessage(MsgTypeBean msgTypeBean, String content){
		RespTextMsg resTextMessage = new RespTextMsg();
		resTextMessage.setFromUserName(msgTypeBean.getToUserName());
		resTextMessage.setToUserName(msgTypeBean.getFromUserName());
		resTextMessage.setContent(content);
		resTextMessage.setCreateTime(System.currentTimeMillis()/1000);
		resTextMessage.setMsgType(WechatReqMsgTypeConstant.TEXT);
		return JavaBean2Xml.convert2Xml(resTextMessage, "xml");
	}
	
	/**
	 * get Image Message xml 
	 * @param msgTypeBean
	 * @param image
	 * @return
	 */
	public String getImageMessage(MsgTypeBean msgTypeBean, ImageBean imageBean){
		RespImageMsg respImageMsg = new RespImageMsg();
		respImageMsg.setFromUserName(msgTypeBean.getToUserName());
		respImageMsg.setToUserName(msgTypeBean.getFromUserName());
		
		respImageMsg.setImageBeans(imageBean);
		respImageMsg.setCreateTime(System.currentTimeMillis()/1000);
		respImageMsg.setMsgType(WechatReqMsgTypeConstant.IMAGE);
		return JavaBean2Xml.convert2Xml(respImageMsg, "xml");
	}
}

@@ -446,21 +446,305 @@
 nse.
-baseBean.Imag
+RespVideoMsg;%0D%0Aimport com.qikemi.wechat.api.entity.message.response.RespVoiceMsg;%0D%0Aimport com.qikemi.wechat.api.entity.message.response.baseBean.ImageBean;%0D%0Aimport com.qikemi.wechat.api.entity.message.response.baseBean.VideoBean;%0D%0Aimport com.qikemi.wechat.api.entity.message.response.baseBean.Voic
 eBea
@@ -1285,22 +1285,18 @@
 getTextM
-essage
+sg
 (MsgType
@@ -1861,22 +1861,18 @@
 etImageM
-essage
+sg
 (MsgType
@@ -2253,24 +2253,24 @@
 nt.IMAGE);%0D%0A
-
 %09%09return Jav
@@ -2317,12 +2317,1176 @@
 %22);%0D%0A%09%7D%0D
+%0A%0D%0A%09/**%0D%0A%09 * get Voice Message xml %0D%0A%09 * @param msgTypeBean%0D%0A%09 * @param imageBean%0D%0A%09 * @return%0D%0A%09 */%0D%0A%09public String getVoiceMsg(MsgTypeBean msgTypeBean, VoiceBean voiceBean) %7B%0D%0A%09%09RespVoiceMsg respVoiceMsg = new RespVoiceMsg();%0D%0A%09%09respVoiceMsg.setFromUserName(msgTypeBean.getToUserName());%0D%0A%09%09respVoiceMsg.setToUserName(msgTypeBean.getFromUserName());%0D%0A%09%09%0D%0A%09%09respVoiceMsg.setVoiceBean(voiceBean);%0D%0A%09%09respVoiceMsg.setCreateTime(System.currentTimeMillis()/1000);%0D%0A%09%09respVoiceMsg.setMsgType(WechatReqMsgTypeConstant.VOICE);%0D%0A%09%09return JavaBean2Xml.convert2Xml(respVoiceMsg, %22xml%22);%0D%0A%09%7D%0D%0A%0D%0A%09/**%0D%0A%09 * get Video Message xml %0D%0A%09 * @param msgTypeBean%0D%0A%09 * @param videoBean%0D%0A%09 * @return%0D%0A%09 */%0D%0A%09public String getVideoMsg(MsgTypeBean msgTypeBean, VideoBean videoBean) %7B%0D%0A%09%09RespVideoMsg respVideoMsg = new RespVideoMsg();%0D%0A%09%09respVideoMsg.setFromUserName(msgTypeBean.getToUserName());%0D%0A%09%09respVideoMsg.setToUserName(msgTypeBean.getFromUserName());%0D%0A%09%09%0D%0A%09%09respVideoMsg.setVideoBean(videoBean);%0D%0A%09%09respVideoMsg.setCreateTime(System.currentTimeMillis()/1000);%0D%0A%09%09respVideoMsg.setMsgType(WechatReqMsgTypeConstant.VIDEO);%0D%0A%09%09return JavaBean2Xml.convert2Xml(respVideoMsg, %22xml%22);%0D%0A%09%7D%0D
 %0A%7D%0D%0A

add get getVoiceMsg and getVedioMsg