package cooper

import (
	"errors"
	"net/url"
)

//同步设备信息
func (that *CooperClient) NewFaceDeviceSyncRequest() *FaceDeviceSyncRequest {
	return &FaceDeviceSyncRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/baiduFace/deviceSync",
		},
	}
}

//FaceDeviceSyncRequest ...
type FaceDeviceSyncRequest struct {
	Request
}

//设备物理id
func (that *FaceDeviceSyncRequest) SetDeviceSn(value string) *FaceDeviceSyncRequest {
	that.initParams()
	that.params.Set("device_sn", value)
	return that
}

//核销关联id
func (that *FaceDeviceSyncRequest) SetDeviceId(value string) *FaceDeviceSyncRequest {
	that.initParams()
	that.params.Set("device_id", value)
	return that
}

//业务分组
func (that *FaceDeviceSyncRequest) SetGroupID(value int64) *FaceDeviceSyncRequest {
	that.initParams()
	that.params.Set("group_id", ToString(value))
	return that
}

//租户绑定状态
func (that *FaceDeviceSyncRequest) SetBindStatus(value int64) *FaceDeviceSyncRequest {
	that.initParams()
	that.params.Set("bind_status", ToString(value))
	return that
}

//旧设备物理id
func (that *FaceDeviceSyncRequest) SetDeviceSnOld(value string) *FaceDeviceSyncRequest {
	that.initParams()
	that.params.Set("device_sn_old", value)
	return that
}

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