package pposRequest

import (
	"errors"
	"net/url"
)

//NewHandCheckBackBraceletRequest 手环机业务接口 （手环回收核验）
func (that *PPOSClient) NewHandCheckBackBraceletRequest() *HandCheckBackBraceletRequest {
	return &HandCheckBackBraceletRequest{
		Request: Request{
			Client: that,
			publicParamsSlice: []string{
				"code",
				"device_id",
			},
			apiAddress: "/enterAdmin/braceletYj/backBracelet",
		},
	}
}

//LockerGetCountRequest ...
type HandCheckBackBraceletRequest struct {
	Request
}

func (that *HandCheckBackBraceletRequest) SetCode(value string) *HandCheckBackBraceletRequest {
	that.initParams()
	that.params.Set("code", value) //手环标识码
	return that
}
func (that *HandCheckBackBraceletRequest) SetDeviceID(value string) *HandCheckBackBraceletRequest {
	that.initParams()
	that.params.Set("device_id", value) //设备编号(验证云提供)
	return that
}

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