package pposRequest

import (
	"net/url"
)

func (that *PPOSClient) NewWaterUse() *WaterUseRequest {
	return &WaterUseRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/ticket/water/useNotice",
		},
	}
}

// WaterUseRequest 请求参数...
type WaterUseRequest struct {
	Request
	UserKey     string `json:"userKey"`      //用户唯一号
	StartTime   string `json:"startTime"`    //开始使用时间(yyyy-MM-dd HH:mm:ss)
	EndTime     string `json:"endTime"`      //结束使用时间(yyyy-MM-dd HH:mm:ss)
	Mac         string `json:"mac"`          //mac 水控 mac
	Timestamp   string `json:"timestamp"`    //时间戳,毫秒
	AppKey      string `json:"appKey"`       //应用 key
}

//SetUserKey ...
func (that *WaterUseRequest) SetUserKey(value string) *WaterUseRequest {
	that.UserKey = value
	return that
}

//SetStartTime ...
func (that *WaterUseRequest) SetStartTime(value string) *WaterUseRequest {
	that.StartTime = value
	return that
}

//SetEndTime ...
func (that *WaterUseRequest) SetEndTime(value string) *WaterUseRequest {
	that.EndTime = value
	return that
}

//SetMac ...
func (that *WaterUseRequest) SetMac(value string) *WaterUseRequest {
	that.Mac = value
	return that
}

//SetTimestamp ...
func (that *WaterUseRequest) SetTimestamp(value string) *WaterUseRequest {
	that.Timestamp = value
	return that
}

//SetAppKey ...
func (that *WaterUseRequest) SetAppKey(value string) *WaterUseRequest {
	that.AppKey = value
	return that
}

//Params ...
func (that *WaterUseRequest) Params() (url.Values, error) {
	var m = make(url.Values)
	m.Set("userKey", that.UserKey)
	m.Set("startTime", that.StartTime)
	m.Set("endTime", that.EndTime)
	m.Set("mac", that.Mac)
	m.Set("timestamp", that.Timestamp)
	m.Set("appKey", that.AppKey)
	return m, nil
}

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