package pposRequest

import (
	"errors"
	"net/url"
)

//场地矩阵获取
func (that *PPOSClient) NewPlatformAliProductGetBookingBoardRequest() *PlatformAliProductGetBookingBoardRequest {
	return &PlatformAliProductGetBookingBoardRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/platform/aliProduct/getBookingBoard",
			publicParamsSlice: []string{
				"product_id",
				"stadium_id",
			},
		}}
}

type PlatformAliProductGetBookingBoardRequest struct {
	Request
}

func (that *PlatformAliProductGetBookingBoardRequest) SetStadiumId(value string) *PlatformAliProductGetBookingBoardRequest {
	that.initParams()
	that.params.Set("stadium_id", value)
	return that
}

func (that *PlatformAliProductGetBookingBoardRequest) SetProductId(value string) *PlatformAliProductGetBookingBoardRequest {
	that.initParams()
	that.params.Set("product_id", value)
	return that
}

func (that *PlatformAliProductGetBookingBoardRequest) SetSelectDate(value string) *PlatformAliProductGetBookingBoardRequest {
	that.initParams()
	that.params.Set("select_date", value)
	return that
}

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