package pposRequest

import (
	"errors"
	"net/url"
)

//获取票券详情
func (that *PPOSClient) NewPlatformAliProductGetTicketDetailRequest() *PlatformAliProductGetTicketDetailRequest {
	return &PlatformAliProductGetTicketDetailRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/platform/aliProduct/getTicketDetail",
			publicParamsSlice: []string{
				"product_id",
				"stadium_id",
			},
		}}
}

type PlatformAliProductGetTicketDetailRequest struct {
	Request
}

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

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

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