package pposRequest

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

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

// XiaoLiYunQrIn 请求参数...
type XiaoLiYunQrInRequest struct {
	Request
	QrCodeStr      string `json:"qr_code_str"` //二维码票据内容(必填)
	ClubId      int64  `json:"club_id"` //标识场馆的 ID (选填)
	DeviceName      string `json:"device_name"` //设备名称(选填)
	Type        int64  `json:"type"` //类型1:验证 (必填/默认是 1)
}

//SetQrCodeStr ...
func (that *XiaoLiYunQrInRequest) SetQrCodeStr(value string) *XiaoLiYunQrInRequest {
	that.QrCodeStr = value
	return that
}

//SetClubId ...
func (that *XiaoLiYunQrInRequest) SetClubId(value int64) *XiaoLiYunQrInRequest {
	that.ClubId = value
	return that
}

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

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

//Params ...
func (that *XiaoLiYunQrInRequest) Params() (url.Values, error) {
	var m = make(url.Values)
	m.Set("qr_code_str", that.QrCodeStr)
	if that.ClubId != 0 {
		m.Set("club_id", utils.ToString(that.ClubId))
	}
	m.Set("device_name", that.DeviceName)
	m.Set("type", utils.ToString(that.Type))
	return m, nil
}

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