package pposRequest

import (
	"errors"
	"net/url"
)

//NewHandDoMemberBraceletRequest 手环机业务接口 （领取手环通知）
func (that *PPOSClient) NewHandDoMemberBraceletRequest() *HandDoMemberBraceletRequest {
	return &HandDoMemberBraceletRequest{
		Request: Request{
			Client: that,
			publicParamsSlice: []string{
				"code",
				"device_id",
				"user_id",
			},
			apiAddress: "/enterAdmin/braceletYj/borrowBraceletCallback",
		},
	}
}

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

func (that *HandDoMemberBraceletRequest) SetCode(value string) *HandDoMemberBraceletRequest {
	that.initParams()
	that.params.Set("code", value) //手环标识码
	return that
}
func (that *HandDoMemberBraceletRequest) SetDeviceID(value string) *HandDoMemberBraceletRequest {
	that.initParams()
	that.params.Set("device_id", value) //设备编号(验证云提供)
	return that
}
func (that *HandDoMemberBraceletRequest) SetUserId(value string) *HandDoMemberBraceletRequest {
	that.initParams()
	that.params.Set("user_id", value) //业务系统用户标识
	return that
}

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