package pposRequest

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

func (that *PPOSClient) NewMcMessageSendRequest() *McMessageSendRequest {
	return &McMessageSendRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/mc/message/send",
		},
	}
}

// McMessageSendRequest 请求参数...
type McMessageSendRequest struct {
	Request
	CompanyId      int64  `json:"company_id"` //公司ID
	BusinessId     int64  `json:"business_id"` //中心ID
	OpenId         string `json:"open_id"` //OpenId
	TempParams     string `json:"temp_params"` //模板变量
	SmsMobile      string `json:"sms_mobile"` //接收手机号
	SmsParams      string `json:"sms_params"` //短信:模板变量
	Url            string `json:"url"` //微信消息:模板用户点击后跳转的URL
	Page           string `json:"page"` //微信消息:跳转页面，仅限本小程序内的页面
	MiniAppId      string `json:"mini_app_id"` //微信消息:小程序appId
	MiniPagePath   string `json:"mini_page_path"` //微信消息:小程序的具体页面路径
	CfgCode        string `json:"cfg_code"` //业务code
	Account        int64  `json:"account"` //接收人员工id
	AccountParams  string `json:"account_params"` //站内信系统消息内容
	MiniOpenId     string `json:"mini_open_id"` //小程序订阅OpenId
	MiniTempParams string `json:"mini_temp_params"` //小程序订阅模板变量
	ExtendField    string `json:"extend_field"` //消息扩展信息
}

//SetCompanyId ...
func (that *McMessageSendRequest) SetCompanyId(value int64) *McMessageSendRequest {
	that.CompanyId = value
	return that
}

//SetBusinessId ...
func (that *McMessageSendRequest) SetBusinessId(value int64) *McMessageSendRequest {
	that.BusinessId = value
	return that
}

//SetOpenId ...
func (that *McMessageSendRequest) SetOpenId(value string) *McMessageSendRequest {
	that.OpenId = value
	return that
}

//SetTempParams ...
func (that *McMessageSendRequest) SetTempParams(value string) *McMessageSendRequest {
	that.TempParams = value
	return that
}

//SetSmsMobile ...
func (that *McMessageSendRequest) SetSmsMobile(value string) *McMessageSendRequest {
	that.SmsMobile = value
	return that
}

//SetSmsParams ...
func (that *McMessageSendRequest) SetSmsParams(value string) *McMessageSendRequest {
	that.SmsParams = value
	return that
}

//SetUrl ...
func (that *McMessageSendRequest) SetUrl(value string) *McMessageSendRequest {
	that.Url = value
	return that
}

//SetPage ...
func (that *McMessageSendRequest) SetPage(value string) *McMessageSendRequest {
	that.Page = value
	return that
}

//SetMiniAppId ...
func (that *McMessageSendRequest) SetMiniAppId(value string) *McMessageSendRequest {
	that.MiniAppId = value
	return that
}

//SetMiniPagePath ...
func (that *McMessageSendRequest) SetMiniPagePath(value string) *McMessageSendRequest {
	that.MiniPagePath = value
	return that
}

//SetCfgCode ...
func (that *McMessageSendRequest) SetCfgCode(value string) *McMessageSendRequest {
	that.CfgCode = value
	return that
}

//SetAccount...
func (that *McMessageSendRequest) SetAccount(value int64) *McMessageSendRequest {
	that.Account = value
	return that
}

//SetAccountParams ...
func (that *McMessageSendRequest) SetAccountParams(value string) *McMessageSendRequest {
	that.AccountParams = value
	return that
}

//SetMiniOpenId ...
func (that *McMessageSendRequest) SetMiniOpenId(value string) *McMessageSendRequest {
	that.MiniOpenId = value
	return that
}

//SetMiniTempParams ...
func (that *McMessageSendRequest) SetMiniTempParams(value string) *McMessageSendRequest {
	that.MiniTempParams = value
	return that
}

//SetExtendField ...
func (that *McMessageSendRequest) SetExtendField(value string) *McMessageSendRequest {
	that.ExtendField = value
	return that
}

//Params ...
func (that *McMessageSendRequest) Params() (url.Values, error) {
	var m = make(url.Values)
	m.Set("company_id", utils.ToString(that.CompanyId))
	m.Set("business_id", utils.ToString(that.BusinessId))
	m.Set("open_id", that.OpenId)
	m.Set("temp_params", that.TempParams)
	m.Set("sms_mobile", that.SmsMobile)
	m.Set("sms_params", that.SmsParams)
	m.Set("url", that.Url)
	m.Set("page", that.Page)
	m.Set("mini_app_id", that.MiniAppId)
	m.Set("mini_page_path", that.MiniPagePath)
	m.Set("cfg_code", that.CfgCode)
	m.Set("account", utils.ToString(that.Account))
	m.Set("account_params", that.AccountParams)
	m.Set("mini_open_id", that.MiniOpenId)
	m.Set("mini_temp_params", that.MiniTempParams)
	m.Set("extend_field", that.ExtendField)
	return m, nil
}

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