package pposRequest

import (
	"errors"
	"net/url"
)

//场地日历获取
func (that *PPOSClient) NewPlatformAliProductGetBookingDailyRequest() *PlatformAliProductGetBookingDailyRequest {
	return &PlatformAliProductGetBookingDailyRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/platform/aliProduct/getBookingDaily",
			publicParamsSlice: []string{
				"product_id",
				"stadium_id",
			},
		}}
}

type PlatformAliProductGetBookingDailyRequest struct {
	Request
}

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

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

//开始时间戳
func (that *PlatformAliProductGetBookingDailyRequest) SetStartTime(value string) *PlatformAliProductGetBookingDailyRequest {
	that.initParams()
	that.params.Set("start_time", value)
	return that
}

//结束时间戳
func (that *PlatformAliProductGetBookingDailyRequest) SetEndTime(value string) *PlatformAliProductGetBookingDailyRequest {
	that.initParams()
	that.params.Set("end_time", value)
	return that
}

//扩展信息
func (that *PlatformAliProductGetBookingDailyRequest) SetExtra(value string) *PlatformAliProductGetBookingDailyRequest {
	that.initParams()
	that.params.Set("extra", value)
	return that
}

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