/**
 * 核心服务接口sdk（golang版）
 *
 * @desc 啪啪运动 核心服务接口sdk
 * ---------------------------------------------------------------------
 * @author		tang <unphp@qq.com>
 * @date		2021-03-03
 * @copyright	core-utils
 * ---------------------------------------------------------------------
 */
package cooper

import (
	"errors"
	"net/url"
)

//NewFaceSyncRequest ... 人脸同步
func (that *CooperClient) NewFaceSyncRequest() *FaceSyncRequest {
	return &FaceSyncRequest{
		Request: Request{
			Client:            that,
			publicParamsSlice: []string{
				//...
			},
			apiAddress: "/baiduFace/localSync",
		},
	}
}

//FaceSyncRequest
type FaceSyncRequest struct {
	Request
}

func (that *FaceSyncRequest) SetGroupID(value string) *FaceSyncRequest {
	that.initParams()
	that.params.Set("group_id", value) //组
	return that
}
func (that *FaceSyncRequest) SetUserID(value string) *FaceSyncRequest {
	that.initParams()
	that.params.Set("user_id", value) //用户id
	return that
}
func (that *FaceSyncRequest) SetUserName(value string) *FaceSyncRequest {
	that.initParams()
	that.params.Set("user_name", value) //用户名
	return that
}
func (that *FaceSyncRequest) SetDeviceIds(value string) *FaceSyncRequest {
	that.initParams()
	that.params.Set("device_ids", value) //设备ID
	return that
}

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