package cooper

import (
	"errors"
	"net/url"
)

//同步设备信息
func (that *CooperClient) NewAlfFaceSyncRequest() *AlfFaceSyncRequest {
	return &AlfFaceSyncRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/alf/sync",
		},
	}
}

//AlfFaceSyncRequest ...
type AlfFaceSyncRequest struct {
	Request
}

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

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

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

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

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

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