package pposRequest

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

//NewGateEnter 获取配置
func (that *PPOSClient) NewGateEnterConfirm() *GateEnterConfirmRequest {
	return &GateEnterConfirmRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/enterAdmin/gate/confirm",
		},
	}
}

//GateEnterRequest 业务类别
type GateEnterConfirmRequest struct {
	Request
	DeviceId string `json:"device_id"` //设备id
	RecordNo string `json:"record_no"` //设备id
	IsQuickNew string `json:"is_quick_new"` //快诺优验证标志
}

func (that *GateEnterConfirmRequest) SetDeviceID(deviceId string) *GateEnterConfirmRequest {
	that.DeviceId = deviceId
	return that
}

func (that *GateEnterConfirmRequest) SetRecordNo(recordNo string) *GateEnterConfirmRequest {
	that.RecordNo = recordNo
	return that
}

func (that *GateEnterConfirmRequest) SetIsQuickNew(isQuickNew string) *GateEnterConfirmRequest {
	that.IsQuickNew = isQuickNew
	return that
}

//Params ...
func (that *GateEnterConfirmRequest) Params() (url.Values, error) {
	that.initParams()
	_params := that.params
	_params.Set("device_id", utils.ToString(that.DeviceId))
	_params.Set("record_no", utils.ToString(that.RecordNo))
	if that.IsQuickNew != "" {
		_params.Set("is_quick_new", that.IsQuickNew)
	}
	return _params, nil
}

//Do ...
func (that *GateEnterConfirmRequest) Do() (bool, error) {
	//
	_, _err := that.Client.GetMpData(that.apiAddress, that)
	if _err != nil {
		return false, _err
	}
	return true, nil
}
