package org.springblade.wx.constant;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;

/**
 * @author: lianghanqiang
 * @description: 微信消息模板
 * @since: 9/6/21 -- 8:16 PM
 */
@Getter
@AllArgsConstructor
public enum MessageTemplate {

	/**
	 * 商户入驻签约
	 */
	INVITATION_SIGN("yAtQ6AY8zBHDT1PxXHv7x7gS-qiN1DnSedN4MWLbHwk", "" +
		"{\n" +
		" \"phrase1\": {\n" +
		"    \"value\": \"%s\"\n" +
		" },\n" +
		" \"thing2\": {\n" +
		"    \"value\": \"%s\"\n" +
		" }\n" +
		"}"),
	PAYMENT_NOTICE("2TcoWv042wo8Bf0SLRkjSLG00JAb9bE-usMy_aAW3Js", "" +
		"{\n" +
		"    \"amount3\":{\n" +
		"        \"value\":\"%s\"\n" +
		"    },\n" +
		"    \"phrase1\":{\n" +
		"        \"value\":\"%s\"\n" +
		"    },\n" +
		"    \"character_string8\":{\n" +
		"        \"value\":\"%s\"\n" +
		"    },\n" +
		"    \"time4\":{\n" +
		"        \"value\":\"%s\"\n" +
		"    }\n" +
		"}"),
	;

	String templateId;
	String contentString;

	public String buildRequestBody(String openId, JSONObject content, String page) {
		HashMap<String, Object> params = new HashMap<>(4);
		params.put("touser", openId);
		params.put("miniprogram_state", "trial");
		params.put("template_id", this.getTemplateId());
		params.put("page", page);
		params.put("data", content);
		return JSON.toJSONString(params);
	}

}
