package pposRequest

import (
	"errors"
	"net/url"
)

//NewHandBackMemberBraceletRequest 手环机业务接口 （归还手环通知）
func (that *PPOSClient) NewHandBackMemberBraceletRequest() *HandBackMemberBraceletRequest {
	return &HandBackMemberBraceletRequest{
		Request: Request{
			Client: that,
			publicParamsSlice: []string{
				"code",
				"device_id",
			},
			apiAddress: "/enterAdmin/braceletYj/backBraceletCallback",
		},
	}
}

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

func (that *HandBackMemberBraceletRequest) SetCode(value string) *HandBackMemberBraceletRequest {
	that.initParams()
	that.params.Set("code", value) //手环标识码
	return that
}
func (that *HandBackMemberBraceletRequest) SetDeviceID(value string) *HandBackMemberBraceletRequest {
	that.initParams()
	that.params.Set("device_id", value) //设备编号(验证云提供)
	return that
}
func (that *HandBackMemberBraceletRequest) SetCheckType(value string) *HandBackMemberBraceletRequest {
	that.initParams()
	that.params.Set("check_type", value) //验证识别类型（1 二维码 2云验证id）
	return that
}
func (that *HandBackMemberBraceletRequest) SetUserId(value string) *HandBackMemberBraceletRequest {
	that.initParams()
	that.params.Set("user_id", value) //业务系统用户标识
	return that
}

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