package cooper

import (
	"encoding/json"
	"errors"
	"net/url"
)


func (that *CooperClient) NewUsrK3LightLineListByModLineRequest() *UsrK3LightLineListByModLineRequest {
	return &UsrK3LightLineListByModLineRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/usrK3/lightLineListByModLine",
		},
	}
}

//UsrK3LightLineListByModLineRequest ...
type UsrK3LightLineListByModLineRequest struct {
	Request
}

//多个灯控ID
func (that *UsrK3LightLineListByModLineRequest) SetLineIds(value string) *UsrK3LightLineListByModLineRequest {
	that.initParams()
	that.params.Set("line_ids", value)
	return that
}

//Params ...
func (that *UsrK3LightLineListByModLineRequest) 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 *UsrK3LightLineListByModLineRequest) Do() (*UsrK3LightLineListByModResponse, error) {
	//返回data
	_data, _err := that.Client.Post(that.apiAddress, that)
	if _err != nil {
		return nil, _err
	}
	//
	_str, _err := json.Marshal(_data)
	if _err != nil {
		return nil, errors.New(that.apiAddress + "Marshal failed!" + _err.Error())
	}
	//返回结果
	_rs := new(UsrK3LightLineListByModResponse)
	_err = json.Unmarshal(_str, &_rs)
	if _err != nil {
		return _rs, errors.New(that.apiAddress + "Unmarshal failed!" + _err.Error())
	}
	return _rs, nil
}
