package pposRequest

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

func (that *PPOSClient) NewXiaoLiYunBraceletCallBack() *XiaoLiYunBraceletCallBackRequest {
	return &XiaoLiYunBraceletCallBackRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/ticket/water/checkAuth",
		},
	}
}

// XiaoLiYunBraceletCallBack 请求参数...
type XiaoLiYunBraceletCallBackRequest struct {
	Request
	Type      int64 `json:"type"` //1:借手环 ,2:还手环(必填)
	BraceletCardNo      string  `json:"bracelet_card_no"` //借/还手环号内码(必填)
	ClubId      string `json:"club_id"` //标识场馆的 ID (选填)
	DeviceName      string `json:"device_name"` //设备名称(选填)
	VerifyType      int64 `json:"verify_type"` //验证类型1: 人脸验证 2: 二维码验证 3: nfc 刷卡验证 (选填 默认是 1)
	VerifyVoucher      string `json:"verify_voucher"` //验证凭证如果是人脸验证,值为 会员卡号 如果是二维码验证 值为二维码内容 如果是 nfc 刷卡验证 值为 nfc 卡号 (选填 默认是会员卡号)
	BraceletNum      string `json:"bracelet_num"` //印在手环上的标记数字
	//注* 还手环时涉及到参数只有 type,bracelet_card_no,device_name,bracelet_num
}

//SetType ...
func (that *XiaoLiYunBraceletCallBackRequest) SetType(value int64) *XiaoLiYunBraceletCallBackRequest {
	that.Type = value
	return that
}

//SetBraceletCardNo ...
func (that *XiaoLiYunBraceletCallBackRequest) SetBraceletCardNo(value string) *XiaoLiYunBraceletCallBackRequest {
	that.BraceletCardNo = value
	return that
}

//SetClubId ...
func (that *XiaoLiYunBraceletCallBackRequest) SetClubId(value string) *XiaoLiYunBraceletCallBackRequest {
	that.ClubId = value
	return that
}

//SetDeviceName ...
func (that *XiaoLiYunBraceletCallBackRequest) SetDeviceName(value string) *XiaoLiYunBraceletCallBackRequest {
	that.DeviceName = value
	return that
}

//SetVerifyType ...
func (that *XiaoLiYunBraceletCallBackRequest) SetVerifyType(value int64) *XiaoLiYunBraceletCallBackRequest {
	that.VerifyType = value
	return that
}

//SetVerifyVoucher ...
func (that *XiaoLiYunBraceletCallBackRequest) SetVerifyVoucher(value string) *XiaoLiYunBraceletCallBackRequest {
	that.VerifyVoucher = value
	return that
}

//SetBraceletNum ...
func (that *XiaoLiYunBraceletCallBackRequest) SetBraceletNum(value string) *XiaoLiYunBraceletCallBackRequest {
	that.BraceletNum = value
	return that
}

//Params ...
func (that *XiaoLiYunBraceletCallBackRequest) Params() (url.Values, error) {
	var m = make(url.Values)
	m.Set("type", utils.ToString(that.Type))
	m.Set("bracelet_card_no", that.BraceletCardNo)
	if that.ClubId != "" {
		m.Set("club_id", that.ClubId)
	}
	m.Set("device_name", that.DeviceName)
	if that.VerifyType != 0 {
		m.Set("verify_type", utils.ToString(that.VerifyType))
	}
	if that.VerifyVoucher != "" {
		m.Set("verify_voucher", that.VerifyVoucher)
	}
	if that.BraceletNum != "" {
		m.Set("bracelet_num", that.BraceletNum)
	}
	return m, nil
}

//Do ...
func (that *XiaoLiYunBraceletCallBackRequest) Do() (interface{}, error) {
	_responData, _err := that.Client.GetData(that.apiAddress, that)
	if _err != nil {
		return nil, _err
	}
	return _responData, nil
}
