package cn.hmsoft.weixin.request;

import java.io.File;
import java.util.HashMap;

import cn.hmsoft.weixin.entity.request.MaterialAddRequestJson;
import cn.hmsoft.weixin.entity.response.MaterialResponseJson;

/********************
 * @note 增加一个多媒体
 * @author revisit@126.com
 * @Company: www.hmsoft.cn
 * @create 2017-05-09 00:16:59
 * @version 4.0.0
 */
public class MaterialAddRequest
		extends AbstractRequest<MaterialResponseJson, MaterialResponseJson, MaterialAddRequestJson> {

	private String type;
	private File localFile;
	private final static String url = "https://api.weixin.qq.com/cgi-bin/material/add_material?";

	/***********************************
	 * @param type
	 *            多媒体类型
	 * @param file
	 *            多媒体文件
	 */
	public MaterialAddRequest(String type, File file) {
		this.type = type;
		this.localFile = file;
	}

	@Override
	protected String makeUrl() {
		this.method = "POST";
		return url + "access_token=" + this.wxDefine.getApp_accesstoken() + "&type=" + type;
	}

	@Override
	protected void httpRequest() {
		try {
			this.httpRequest(localFile, new HashMap<String, String>());
		} catch (Exception e) {
		}
	}

}
