package pposRequest

import (
	"net/url"
)

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

// XiaoLiYunCheckIn 请求参数...
type XiaoLiYunCheckInRequest struct {
	Request
	CardNo      string `json:"card_no"` //卡号(ic 卡内码,读卡器读出来的卡号)。如无实体卡号,传入手机号码或 用户 ID 作为卡号(必填)
	DeviceName      string `json:"device_name"` //带权限入场的设备名称(选填)
	ClubId      string  `json:"club_id"` //标识场馆的 ID (选填)
}

//SetCardNo ...
func (that *XiaoLiYunCheckInRequest) SetCardNo(value string) *XiaoLiYunCheckInRequest {
	that.CardNo = value
	return that
}

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

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

//Params ...
func (that *XiaoLiYunCheckInRequest) Params() (url.Values, error) {
	var m = make(url.Values)
	m.Set("card_no", that.CardNo)
	m.Set("device_name", that.DeviceName)
	if that.ClubId != "" {
		m.Set("club_id", that.ClubId)
	}
	return m, nil
}

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