package cooper

import (
	"errors"
	"net/url"
)

//修改灯路配置
func (that *CooperClient) NewUsrK3LightModEditRequest() *UsrK3LightModEditRequest {
	return &UsrK3LightModEditRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/usrK3/lightModEdit",
		},
	}
}

//UsrK3LightModEditRequest ...
type UsrK3LightModEditRequest struct {
	Request
}

//模组id
func (that *UsrK3LightModEditRequest) SetModId(value int64) *UsrK3LightModEditRequest {
	that.initParams()
	that.params.Set("mod_id", ToString(value))
	return that
}

//设备ID
func (that *UsrK3LightModEditRequest) SetDevId(value string) *UsrK3LightModEditRequest {
	that.initParams()
	that.params.Set("dev_id", value)
	return that
}

//开关模块名称
func (that *UsrK3LightModEditRequest) SetModName(value string) *UsrK3LightModEditRequest {
	that.initParams()
	that.params.Set("mod_name", value)
	return that
}

//设备拨片编号
func (that *UsrK3LightModEditRequest) SetModSort(value int64) *UsrK3LightModEditRequest {
	that.initParams()
	that.params.Set("mod_sort", ToString(value))
	return that
}

//设备类型
func (that *UsrK3LightModEditRequest) SetModType(value int64) *UsrK3LightModEditRequest {
	that.initParams()
	that.params.Set("mod_type", ToString(value))
	return that
}

//Params ...
func (that *UsrK3LightModEditRequest) 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 *UsrK3LightModEditRequest) Do() (interface{}, error) {
	//返回data
	_data, _err := that.Client.Post(that.apiAddress, that)
	if _err != nil {
		return nil, _err
	}
	return _data, nil
}
