package pposRequest

import (
	"PPOSUtils/utils"
	"net/url"
)

//NewWxMpTempSend 微信消息发送
func (that *PPOSClient) NewWxMpTempSend() *WxMpTempSendRequest {
	return &WxMpTempSendRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/wxMp/temp/send",
		},
		MpAppId:    "/",
		MpPagePath: "http://",
	}
}

//CfgTradeGetByIdRequest ...
type WxMpTempSendRequest struct {
	Request
	TempId     string `param:"<in:formData> <desc:TmpId> "`
	OpenId     string `param:"<in:formData> <desc:OpenId> "`
	TempParams string `param:"<in:formData> <desc:Data> "`
	MpAppId    string `param:"<in:formData> <desc:MpAppId> "`
	MpPagePath string `param:"<in:formData> <desc:MpPagePath> "`
}

func (that *WxMpTempSendRequest) SetTempId(value string) *WxMpTempSendRequest {
	that.TempId = value
	return that
}
func (that *WxMpTempSendRequest) SetOpenId(value string) *WxMpTempSendRequest {
	that.OpenId = value
	return that
}
func (that *WxMpTempSendRequest) SetTempParams(value string) *WxMpTempSendRequest {
	that.TempParams = value
	return that
}

//Params ...
func (that *WxMpTempSendRequest) Params() (url.Values, error) {
	that.initParams()
	m := that.params
	m.Set("temp_id", utils.ToString(that.TempId))
	m.Set("open_id", utils.ToString(that.OpenId))
	m.Set("temp_params", utils.ToString(that.TempParams))
	m.Set("mp_app_id", utils.ToString(that.MpAppId))
	m.Set("mp_page_path", utils.ToString(that.MpPagePath))
	return m, nil
}

//Do ...
func (that *WxMpTempSendRequest) Do() (interface{}, error) {
	_data, _err := that.Client.GetData(that.apiAddress, that)
	if _err != nil {
		return nil, _err
	}
	//
	return _data, nil
}
