package cooper

import (
	"PPOSUtils/utils"
	"net/url"
)

//NewFaceUserAddRequest ...
func (that *CooperClient) NewFaceDeviceCheckRequest() *FaceDeviceCheckRequest {
	return &FaceDeviceCheckRequest{
		Client:     that,
		apiAddress: "/baiduFace/deviceCheck",
	}
}

//FaceDeviceCheckRequest ...
type FaceDeviceCheckRequest struct {
	Client      *CooperClient
	apiAddress  string
	PersonId    string `json:"person_id"`
	DeviceSn    string `json:"device_sn"` //用户分组id
	AlarmId     string `json:"alarm_id"`
	CaptureTime string `json:"capture_time"`
	Qrcode      string `json:"qrcode"`
	IcCard      string `json:"ic_card"`
	IdCard      string `json:"id_card"`
}

//SetData...
func (that *FaceDeviceCheckRequest) SetDeviceSn(deviceSn string) *FaceDeviceCheckRequest {
	that.DeviceSn = utils.ToString(deviceSn)
	return that
}

func (that *FaceDeviceCheckRequest) SetPersonId(personId string) *FaceDeviceCheckRequest {
	that.PersonId = personId
	return that
}

func (that *FaceDeviceCheckRequest) SetAlarmId(val string) *FaceDeviceCheckRequest {
	that.AlarmId = val
	return that
}

func (that *FaceDeviceCheckRequest) SetCaptureTime(val string) *FaceDeviceCheckRequest {
	that.CaptureTime = val
	return that
}

func (that *FaceDeviceCheckRequest) SetQrcode(qrcode string) *FaceDeviceCheckRequest {
	that.Qrcode = qrcode
	return that
}

func (that *FaceDeviceCheckRequest) SetIcCard(icCard string) *FaceDeviceCheckRequest {
	that.IcCard = icCard
	return that
}

func (that *FaceDeviceCheckRequest) SetIdCard(idCard string) *FaceDeviceCheckRequest {
	that.IdCard = idCard
	return that
}

//Params ...
func (that *FaceDeviceCheckRequest) Params() (url.Values, error) {
	var m = make(url.Values)
	m.Set("device_sn", that.DeviceSn)
	m.Set("person_id", that.PersonId)
	m.Set("alarm_id", that.AlarmId)
	m.Set("capture_time", that.CaptureTime)
	m.Set("qrcode", that.Qrcode)
	m.Set("ic_card", that.IcCard)
	m.Set("id_card", that.IdCard)
	return m, nil
}

//Do ...
func (that *FaceDeviceCheckRequest) Do() (interface{}, error) {
	_data, _err := that.Client.Post(that.apiAddress, that)
	if _err != nil {
		return "", _err
	}
	return _data, nil
}
