package cooper

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

//NewFaceDeviceConfirmRequest ...
func (that *CooperClient) NewFaceDeviceConfirmRequest() *FaceDeviceConfirmRequest {
	return &FaceDeviceConfirmRequest{
		Client:     that,
		apiAddress: "/baiduFace/deviceConfirm",
	}
}

//FaceDeviceConfirmRequest ...
type FaceDeviceConfirmRequest struct {
	Client      *CooperClient
	apiAddress  string
	PersonId    string `json:"person_id"`
	DeviceSn    string `json:"device_sn"`
	AlarmId     string `json:"alarm_id"`
	CaptureTime string `json:"capture_time"`
	SessionId   string `json:"session_id"`
	Qrcode      string `json:"qrcode"`
	IcCard      string `json:"ic_card"`
	IdCard      string `json:"id_card"`
}

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

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

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

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

func (that *FaceDeviceConfirmRequest) SetSessionId(sessionId string) *FaceDeviceConfirmRequest {
	that.SessionId = sessionId
	return that
}

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

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

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

//Params ...
func (that *FaceDeviceConfirmRequest) 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("session_id", that.SessionId)
	m.Set("qrcode", that.Qrcode)
	m.Set("ic_card", that.IcCard)
	m.Set("id_card", that.IdCard)
	return m, nil
}

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