package earlyWarning

import (
	"PPOSUtils/utils"
	"encoding/json"
)

//NewEarlyWarning ...
func (that *UdpClient) NewEarlyWarning() *EarlyWarningRequest {
	return &EarlyWarningRequest{
		Request: Request{
			Client: that,
		},
		apiAddress: "earlyWarning",
	}
}

//EarlyWarningRequest 预警
type EarlyWarningRequest struct {
	Request
	apiAddress string
	params     utils.Mp
}

func (that *EarlyWarningRequest) initParams() {
	that.params = utils.NewMP()
}

func (that *EarlyWarningRequest) SetCode(value string) *EarlyWarningRequest {
	that.initParams()
	that.params.Set("code", value)
	return that
}

//Do ...
func (that *EarlyWarningRequest) Do() *EarlyWarningRequest {
	_json, _ := json.Marshal(that.params)
	that.Push("", _json)
	return that
}
