/**
 * 核心服务接口sdk（golang版）
 *
 * @desc 啪啪运动 核心服务接口sdk
 * ---------------------------------------------------------------------
 * @author		unphp <unphp@qq.com>
 * @date		2018-12-18
 * @copyright	core-utils
 * ---------------------------------------------------------------------
 */

package pposRequest

import (
	"errors"
	"net/url"
)

//new...
func (that *PPOSClient) NewMessageSend() *MessageSendRequest {
	return &MessageSendRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/mc/message/send",
		},
	}
}

//Request...
type MessageSendRequest struct {
	Request
}

func (that *MessageSendRequest) SetCfgCode(value string) *MessageSendRequest {
	that.initParams()
	that.params.Set("cfg_code", value)
	return that
}
func (that *MessageSendRequest) SetSmsMobile(value string) *MessageSendRequest {
	that.initParams()
	that.params.Set("sms_mobile", value)
	return that
}
func (that *MessageSendRequest) SetSmsParams(value string) *MessageSendRequest {
	that.initParams()
	that.params.Set("sms_params", value)
	return that
}

//Params ...
func (that *MessageSendRequest) Params() (url.Values, error) {
	that.initParams()
	_params := that.params
	if that.publicParamsSlice != nil {
		for _, _v := range that.publicParamsSlice {
			if _params.Get(_v) == "" {
				return nil, errors.New(that.apiAddress + "缺少参数:" + _v)
			}
		}
	}
	return _params, nil

}

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