package cooper

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


func (that *CooperClient) NewUsrK3LightLineListByModRequest() *UsrK3LightLineListByModRequest {
	return &UsrK3LightLineListByModRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/usrK3/lightLineListByMod",
		},
	}
}

//UsrK3LightLineListByModRequest ...
type UsrK3LightLineListByModRequest struct {
	Request
}

//多个灯控ID
func (that *UsrK3LightLineListByModRequest) SetIdentifiers(value string) *UsrK3LightLineListByModRequest {
	that.initParams()
	that.params.Set("identifiers", ToString(value))
	return that
}

//Params ...
func (that *UsrK3LightLineListByModRequest) 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
}

type UsrK3LightLineListByModResponse struct {
	Page int64 `json:"page"`
	Size int64 `json:"size"`
	Count int64 `json:"count"`
	List []*UsrK3LightLineListByModTemp `json:"list"`
}

type UsrK3LightLineListByModTemp struct {
	Identifier string `json:"identifier"`
	LightName  string `json:"light_name"`
	LineId     string `json:"line_id"`
	LineName     string `json:"line_name"`
	IsEnable   int64 `json:"is_enable"`
}


//Do ...
func (that *UsrK3LightLineListByModRequest) 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
}
