/*
Copyright (C) 2025 filifa

This file is part of mlbstats.

mlbstats is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.

mlbstats is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with
mlbstats. If not, see <https://www.gnu.org/licenses/>.
*/

/*
 * Stats API Documentation
 *
 * Official API for Major League Baseball.
 *
 * API version: 2.0.0
 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
 */
package api

import (
	"context"
	"github.com/antihax/optional"
	"io/ioutil"
	"net/http"
	"net/url"
	"scm.dairydemon.net/filifa/mlbstats/api/models"
	"strings"
)

// Linger please
var (
	_ context.Context
)

type StatsApiService service

/*
StatsApiService View stats from search
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param group Category of statistic to return. Available types in /api/v1/statGroups
 * @param optional nil or *StatsApiBeastStatsOpts - Optional Parameters:
     * @param "GamePks" (optional.Interface of []int32) -  Comma delimited list of unique primary keys
     * @param "PlayIds" (optional.Interface of []string) -  Comma delimited list of unique play identifiers
     * @param "Seasons" (optional.Interface of []string) -  Comma delimited list of Seasons of play
     * @param "GameTypes" (optional.Interface of []models.GameTypeEnum) -  Type of Game. Available types in /api/v1/gameTypes
     * @param "Date" (optional.String) -  Date of Game. Format: YYYY-MM-DD
     * @param "StartDate" (optional.String) -  Date of Game. Format: YYYY-MM-DD
     * @param "EndDate" (optional.String) -  Date of Game. Format: YYYY-MM-DD
     * @param "TeamIds" (optional.Interface of []int32) -  Unique Team Identifier. Format: 141, 147, etc
     * @param "PitcherTeamIds" (optional.Interface of []int32) -  Unique Team Identifier. Format: 141, 147, etc
     * @param "BatterTeamIds" (optional.Interface of []int32) -  Unique Team Identifier. Format: 141, 147, etc
     * @param "SportIds" (optional.Interface of []int32) -  Comma delimited list of top level organizations of a sport
     * @param "PitcherSportIds" (optional.Interface of []int32) -  Comma delimited list of top level organizations of a sport
     * @param "BatterSportIds" (optional.Interface of []int32) -  Comma delimited list of top level organizations of a sport
     * @param "LeagueIds" (optional.Interface of []int32) -  Comma delimited list of Unique league identifiers
     * @param "PitcherLeagueIds" (optional.Interface of []int32) -  Comma delimited list of Unique league identifiers
     * @param "BatterLeagueIds" (optional.Interface of []int32) -  Comma delimited list of Unique league identifiers
     * @param "DivisionIds" (optional.Interface of []int32) -  Comma delimited list of Unique League Identifiers
     * @param "PitcherDivisionIds" (optional.Interface of []int32) -  Comma delimited list of Unique League Identifiers
     * @param "BatterDivisionIds" (optional.Interface of []int32) -  Comma delimited list of Unique League Identifiers
     * @param "PitchersOnTeamIds" (optional.Interface of []int32) -  Unique Team Identifier. Format: 141, 147, etc
     * @param "BattersOnTeamIds" (optional.Interface of []int32) -  Unique Team Identifier. Format: 141, 147, etc
     * @param "PlayerIds" (optional.Interface of []int32) -  A unique identifier for a player
     * @param "PlayerPool" (optional.Interface of PlayerPoolEnum) -  Return \&quot;ALL\&quot; or only \&quot;QUALIFIED\&quot; players based on plate appearances.
     * @param "PitcherIds" (optional.Interface of []int32) -  A unique identifier for a player
     * @param "BatterIds" (optional.Interface of []int32) -  A unique identifier for a player
     * @param "CatcherIds" (optional.Interface of []int32) -  A unique identifier for a player
     * @param "FirstBasemanIds" (optional.Interface of []int32) -  A unique identifier for a player
     * @param "SecondBasemanIds" (optional.Interface of []int32) -  A unique identifier for a player
     * @param "ThirdBasemanIds" (optional.Interface of []int32) -  A unique identifier for a player
     * @param "ShortstopIds" (optional.Interface of []int32) -  A unique identifier for a player
     * @param "LeftFielderIds" (optional.Interface of []int32) -  A unique identifier for a player
     * @param "CenterFielderIds" (optional.Interface of []int32) -  A unique identifier for a player
     * @param "RightFielderIds" (optional.Interface of []int32) -  A unique identifier for a player
     * @param "RunnerFirstIds" (optional.Interface of []int32) -  A unique identifier for a player
     * @param "RunnerSecondIds" (optional.Interface of []int32) -  A unique identifier for a player
     * @param "RunnerThirdIds" (optional.Interface of []int32) -  A unique identifier for a player
     * @param "VenueIds" (optional.Interface of []int32) -  Unique Venue Identifier
     * @param "PitchHand" (optional.String) -  Handedness of pitcher
     * @param "BatSide" (optional.String) -  Bat side of hitter
     * @param "PitchTypes" (optional.Interface of []PitchType) -  Classification of pitch (fastball, curveball, etc...)
     * @param "PitchCodes" (optional.Interface of []PitchCode) -  Result of the pitch (ball, called strike, etc...)
     * @param "EventTypes" (optional.Interface of []EventType) -  Type of event
     * @param "Positions" (optional.Interface of []models.BaseballPosition) -  All of the details of a player&#x27;s position
     * @param "PrimaryPositions" (optional.Interface of []models.BaseballPosition) -  All of the details of a player&#x27;s position
     * @param "MinPitchSpeed" (optional.Float64) -  Minimum value to filter on
     * @param "MaxPitchSpeed" (optional.Float64) -  Maximum value to filter on
     * @param "MinSpinRate" (optional.Float64) -  Minimum value to filter on
     * @param "MaxSpinRate" (optional.Float64) -  Maximum value to filter on
     * @param "MinExtension" (optional.Float64) -  Minimum value to filter on
     * @param "MaxExtension" (optional.Float64) -  Maximum value to filter on
     * @param "MinExitVelocityAgainst" (optional.Float64) -  Minimum value to filter on
     * @param "MaxExitVelocityAgainst" (optional.Float64) -  Maximum value to filter on
     * @param "MinLaunchAngleAgainst" (optional.Float64) -  Minimum value to filter on
     * @param "MaxLaunchAngleAgainst" (optional.Float64) -  Maximum value to filter on
     * @param "MinExitVelocity" (optional.Float64) -  Minimum value to filter on
     * @param "MaxExitVelocity" (optional.Float64) -  Maximum value to filter on
     * @param "MinLaunchAngle" (optional.Float64) -  Minimum value to filter on
     * @param "MaxLaunchAngle" (optional.Float64) -  Maximum value to filter on
     * @param "MinHomeRunDistance" (optional.Float64) -  Minimum value to filter on
     * @param "MaxHomeRunDistance" (optional.Float64) -  Maximum value to filter on
     * @param "MinHitDistance" (optional.Float64) -  Minimum value to filter on
     * @param "MaxHitDistance" (optional.Float64) -  Maximum value to filter on
     * @param "MinHangTime" (optional.Float64) -  Minimum value to filter on
     * @param "MaxHangTime" (optional.Float64) -  Maximum value to filter on
     * @param "MinHitProbability" (optional.Float64) -  Minimum value to filter on
     * @param "MaxHitProbability" (optional.Float64) -  Maximum value to filter on
     * @param "MinCatchProbability" (optional.Float64) -  Minimum value to filter on
     * @param "MaxCatchProbability" (optional.Float64) -  Maximum value to filter on
     * @param "MinAttackAngle" (optional.Float64) -  Minimum value to filter on
     * @param "MaxAttackAngle" (optional.Float64) -  Maximum value to filter on
     * @param "MinBatSpeed" (optional.Float64) -  Minimum value to filter on
     * @param "MaxBatSpeed" (optional.Float64) -  Maximum value to filter on
     * @param "MinHomeRunXBallparks" (optional.Float64) -  Minimum value to filter on
     * @param "MaxHomeRunXBallparks" (optional.Float64) -  Maximum value to filter on
     * @param "IsBarrel" (optional.Bool) -  Whether or not a play resulted in a barreled ball
     * @param "HitTrajectories" (optional.Interface of []HitTrajectory) -  Trajectory of hit (line drive, fly ball, etc...)
     * @param "Limit" (optional.Int32) -  Number of results to return
     * @param "Offset" (optional.Int32) -  The pointer to start for a return set; used for pagination
     * @param "GroupBy" (optional.Interface of []models.GroupByEnum) -  Group stats by PLAYER, TEAM, SEASON, VENUE, SPORT or STAT_GROUP
     * @param "CompareOver" (optional.Interface of []models.GroupByEnum) -  Group stats by PLAYER, TEAM, SEASON, VENUE, SPORT or STAT_GROUP
     * @param "SortStat" (optional.Interface of BaseballStatsEnum) -  Baseball stat to sort splits by.
     * @param "SortModifier" (optional.Interface of AggregateSortTypeEnum) -  The prefix modifier for the sort stat.  avg, min, max. I.E minExitVelocity, maxLaunchAngle, avgHitDistance
     * @param "SortOrder" (optional.Interface of SortOrderEnum) -  The order of sorting, ascending or descending
     * @param "Percentile" (optional.Int32) -  Only return averages above this percentile. used for best effort plays
     * @param "MinOccurrences" (optional.Int32) -  Minimum occurrences to filter upon
     * @param "MinPlateAppearances" (optional.Int32) -  Minimum occurrences to filter upon
     * @param "MinInnings" (optional.Int32) -  Minimum occurrences to filter upon
     * @param "QualifierRate" (optional.Float64) -  Minimum occurrences to filter upon
     * @param "SitCodes" (optional.Interface of []string) -  Situation code for a given stat split.
     * @param "ShowTotals" (optional.Bool) -  Columns to return totals
     * @param "IncludeNullMetrics" (optional.Bool) -  Show events with null metrics
     * @param "StatFields" (optional.Interface of []StatField) -  Baseball stat fields to populate
     * @param "AtBatNumbers" (optional.Interface of []int32) -  The at bat number of a given game. Format: 1, 2, 3, etc
     * @param "PitchNumbers" (optional.Interface of []int32) -  The pitch number of a given game. Format: 1, 2, 3, etc
     * @param "Fields" (optional.Interface of []string) -  Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
     * @param "Debug" (optional.Bool) -
     * @param "ActiveStatus" (optional.Interface of PlayerActiveStatusEnum) -  Whether or not a player is active
@return models.StatContainerRestObject
*/

type StatsApiBeastStatsOpts struct {
	GamePks                optional.Interface
	PlayIds                optional.Interface
	Seasons                optional.Interface
	GameTypes              optional.Interface
	Date                   optional.String
	StartDate              optional.String
	EndDate                optional.String
	TeamIds                optional.Interface
	PitcherTeamIds         optional.Interface
	BatterTeamIds          optional.Interface
	SportIds               optional.Interface
	PitcherSportIds        optional.Interface
	BatterSportIds         optional.Interface
	LeagueIds              optional.Interface
	PitcherLeagueIds       optional.Interface
	BatterLeagueIds        optional.Interface
	DivisionIds            optional.Interface
	PitcherDivisionIds     optional.Interface
	BatterDivisionIds      optional.Interface
	PitchersOnTeamIds      optional.Interface
	BattersOnTeamIds       optional.Interface
	PlayerIds              optional.Interface
	PlayerPool             optional.Interface
	PitcherIds             optional.Interface
	BatterIds              optional.Interface
	CatcherIds             optional.Interface
	FirstBasemanIds        optional.Interface
	SecondBasemanIds       optional.Interface
	ThirdBasemanIds        optional.Interface
	ShortstopIds           optional.Interface
	LeftFielderIds         optional.Interface
	CenterFielderIds       optional.Interface
	RightFielderIds        optional.Interface
	RunnerFirstIds         optional.Interface
	RunnerSecondIds        optional.Interface
	RunnerThirdIds         optional.Interface
	VenueIds               optional.Interface
	PitchHand              optional.String
	BatSide                optional.String
	PitchTypes             optional.Interface
	PitchCodes             optional.Interface
	EventTypes             optional.Interface
	Positions              optional.Interface
	PrimaryPositions       optional.Interface
	MinPitchSpeed          optional.Float64
	MaxPitchSpeed          optional.Float64
	MinSpinRate            optional.Float64
	MaxSpinRate            optional.Float64
	MinExtension           optional.Float64
	MaxExtension           optional.Float64
	MinExitVelocityAgainst optional.Float64
	MaxExitVelocityAgainst optional.Float64
	MinLaunchAngleAgainst  optional.Float64
	MaxLaunchAngleAgainst  optional.Float64
	MinExitVelocity        optional.Float64
	MaxExitVelocity        optional.Float64
	MinLaunchAngle         optional.Float64
	MaxLaunchAngle         optional.Float64
	MinHomeRunDistance     optional.Float64
	MaxHomeRunDistance     optional.Float64
	MinHitDistance         optional.Float64
	MaxHitDistance         optional.Float64
	MinHangTime            optional.Float64
	MaxHangTime            optional.Float64
	MinHitProbability      optional.Float64
	MaxHitProbability      optional.Float64
	MinCatchProbability    optional.Float64
	MaxCatchProbability    optional.Float64
	MinAttackAngle         optional.Float64
	MaxAttackAngle         optional.Float64
	MinBatSpeed            optional.Float64
	MaxBatSpeed            optional.Float64
	MinHomeRunXBallparks   optional.Float64
	MaxHomeRunXBallparks   optional.Float64
	IsBarrel               optional.Bool
	HitTrajectories        optional.Interface
	Limit                  optional.Int32
	Offset                 optional.Int32
	GroupBy                optional.Interface
	CompareOver            optional.Interface
	SortStat               optional.Interface
	SortModifier           optional.Interface
	SortOrder              optional.Interface
	Percentile             optional.Int32
	MinOccurrences         optional.Int32
	MinPlateAppearances    optional.Int32
	MinInnings             optional.Int32
	QualifierRate          optional.Float64
	SitCodes               optional.Interface
	ShowTotals             optional.Bool
	IncludeNullMetrics     optional.Bool
	StatFields             optional.Interface
	AtBatNumbers           optional.Interface
	PitchNumbers           optional.Interface
	Fields                 optional.Interface
	Debug                  optional.Bool
	ActiveStatus           optional.Interface
}

func (a *StatsApiService) BeastStats(ctx context.Context, group []models.StatGroup, localVarOptionals *StatsApiBeastStatsOpts) (models.StatContainerRestObject, *http.Response, error) {
	var (
		localVarHttpMethod  = strings.ToUpper("Get")
		localVarPostBody    interface{}
		localVarFileName    string
		localVarFileBytes   []byte
		localVarReturnValue models.StatContainerRestObject
	)

	// create path and map variables
	localVarPath := a.client.cfg.BasePath + "/api/v1/stats/search"

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}

	localVarQueryParams.Add("group", parameterToString(group, "multi"))
	if localVarOptionals != nil && localVarOptionals.GamePks.IsSet() {
		localVarQueryParams.Add("gamePks", parameterToString(localVarOptionals.GamePks.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PlayIds.IsSet() {
		localVarQueryParams.Add("playIds", parameterToString(localVarOptionals.PlayIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Seasons.IsSet() {
		localVarQueryParams.Add("seasons", parameterToString(localVarOptionals.Seasons.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.GameTypes.IsSet() {
		localVarQueryParams.Add("gameTypes", parameterToString(localVarOptionals.GameTypes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Date.IsSet() {
		localVarQueryParams.Add("date", parameterToString(localVarOptionals.Date.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.StartDate.IsSet() {
		localVarQueryParams.Add("startDate", parameterToString(localVarOptionals.StartDate.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.EndDate.IsSet() {
		localVarQueryParams.Add("endDate", parameterToString(localVarOptionals.EndDate.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.TeamIds.IsSet() {
		localVarQueryParams.Add("teamIds", parameterToString(localVarOptionals.TeamIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PitcherTeamIds.IsSet() {
		localVarQueryParams.Add("pitcherTeamIds", parameterToString(localVarOptionals.PitcherTeamIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.BatterTeamIds.IsSet() {
		localVarQueryParams.Add("batterTeamIds", parameterToString(localVarOptionals.BatterTeamIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.SportIds.IsSet() {
		localVarQueryParams.Add("sportIds", parameterToString(localVarOptionals.SportIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PitcherSportIds.IsSet() {
		localVarQueryParams.Add("pitcherSportIds", parameterToString(localVarOptionals.PitcherSportIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.BatterSportIds.IsSet() {
		localVarQueryParams.Add("batterSportIds", parameterToString(localVarOptionals.BatterSportIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.LeagueIds.IsSet() {
		localVarQueryParams.Add("leagueIds", parameterToString(localVarOptionals.LeagueIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PitcherLeagueIds.IsSet() {
		localVarQueryParams.Add("pitcherLeagueIds", parameterToString(localVarOptionals.PitcherLeagueIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.BatterLeagueIds.IsSet() {
		localVarQueryParams.Add("batterLeagueIds", parameterToString(localVarOptionals.BatterLeagueIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.DivisionIds.IsSet() {
		localVarQueryParams.Add("divisionIds", parameterToString(localVarOptionals.DivisionIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PitcherDivisionIds.IsSet() {
		localVarQueryParams.Add("pitcherDivisionIds", parameterToString(localVarOptionals.PitcherDivisionIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.BatterDivisionIds.IsSet() {
		localVarQueryParams.Add("batterDivisionIds", parameterToString(localVarOptionals.BatterDivisionIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PitchersOnTeamIds.IsSet() {
		localVarQueryParams.Add("pitchersOnTeamIds", parameterToString(localVarOptionals.PitchersOnTeamIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.BattersOnTeamIds.IsSet() {
		localVarQueryParams.Add("battersOnTeamIds", parameterToString(localVarOptionals.BattersOnTeamIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PlayerIds.IsSet() {
		localVarQueryParams.Add("playerIds", parameterToString(localVarOptionals.PlayerIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PlayerPool.IsSet() {
		localVarQueryParams.Add("playerPool", parameterToString(localVarOptionals.PlayerPool.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.PitcherIds.IsSet() {
		localVarQueryParams.Add("pitcherIds", parameterToString(localVarOptionals.PitcherIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.BatterIds.IsSet() {
		localVarQueryParams.Add("batterIds", parameterToString(localVarOptionals.BatterIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.CatcherIds.IsSet() {
		localVarQueryParams.Add("catcherIds", parameterToString(localVarOptionals.CatcherIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.FirstBasemanIds.IsSet() {
		localVarQueryParams.Add("firstBasemanIds", parameterToString(localVarOptionals.FirstBasemanIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.SecondBasemanIds.IsSet() {
		localVarQueryParams.Add("secondBasemanIds", parameterToString(localVarOptionals.SecondBasemanIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.ThirdBasemanIds.IsSet() {
		localVarQueryParams.Add("thirdBasemanIds", parameterToString(localVarOptionals.ThirdBasemanIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.ShortstopIds.IsSet() {
		localVarQueryParams.Add("shortstopIds", parameterToString(localVarOptionals.ShortstopIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.LeftFielderIds.IsSet() {
		localVarQueryParams.Add("leftFielderIds", parameterToString(localVarOptionals.LeftFielderIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.CenterFielderIds.IsSet() {
		localVarQueryParams.Add("centerFielderIds", parameterToString(localVarOptionals.CenterFielderIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.RightFielderIds.IsSet() {
		localVarQueryParams.Add("rightFielderIds", parameterToString(localVarOptionals.RightFielderIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.RunnerFirstIds.IsSet() {
		localVarQueryParams.Add("runnerFirstIds", parameterToString(localVarOptionals.RunnerFirstIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.RunnerSecondIds.IsSet() {
		localVarQueryParams.Add("runnerSecondIds", parameterToString(localVarOptionals.RunnerSecondIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.RunnerThirdIds.IsSet() {
		localVarQueryParams.Add("runnerThirdIds", parameterToString(localVarOptionals.RunnerThirdIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.VenueIds.IsSet() {
		localVarQueryParams.Add("venueIds", parameterToString(localVarOptionals.VenueIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PitchHand.IsSet() {
		localVarQueryParams.Add("pitchHand", parameterToString(localVarOptionals.PitchHand.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.BatSide.IsSet() {
		localVarQueryParams.Add("batSide", parameterToString(localVarOptionals.BatSide.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.PitchTypes.IsSet() {
		localVarQueryParams.Add("pitchTypes", parameterToString(localVarOptionals.PitchTypes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PitchCodes.IsSet() {
		localVarQueryParams.Add("pitchCodes", parameterToString(localVarOptionals.PitchCodes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.EventTypes.IsSet() {
		localVarQueryParams.Add("eventTypes", parameterToString(localVarOptionals.EventTypes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Positions.IsSet() {
		localVarQueryParams.Add("positions", parameterToString(localVarOptionals.Positions.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PrimaryPositions.IsSet() {
		localVarQueryParams.Add("primaryPositions", parameterToString(localVarOptionals.PrimaryPositions.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.MinPitchSpeed.IsSet() {
		localVarQueryParams.Add("minPitchSpeed", parameterToString(localVarOptionals.MinPitchSpeed.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MaxPitchSpeed.IsSet() {
		localVarQueryParams.Add("maxPitchSpeed", parameterToString(localVarOptionals.MaxPitchSpeed.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MinSpinRate.IsSet() {
		localVarQueryParams.Add("minSpinRate", parameterToString(localVarOptionals.MinSpinRate.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MaxSpinRate.IsSet() {
		localVarQueryParams.Add("maxSpinRate", parameterToString(localVarOptionals.MaxSpinRate.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MinExtension.IsSet() {
		localVarQueryParams.Add("minExtension", parameterToString(localVarOptionals.MinExtension.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MaxExtension.IsSet() {
		localVarQueryParams.Add("maxExtension", parameterToString(localVarOptionals.MaxExtension.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MinExitVelocityAgainst.IsSet() {
		localVarQueryParams.Add("minExitVelocityAgainst", parameterToString(localVarOptionals.MinExitVelocityAgainst.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MaxExitVelocityAgainst.IsSet() {
		localVarQueryParams.Add("maxExitVelocityAgainst", parameterToString(localVarOptionals.MaxExitVelocityAgainst.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MinLaunchAngleAgainst.IsSet() {
		localVarQueryParams.Add("minLaunchAngleAgainst", parameterToString(localVarOptionals.MinLaunchAngleAgainst.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MaxLaunchAngleAgainst.IsSet() {
		localVarQueryParams.Add("maxLaunchAngleAgainst", parameterToString(localVarOptionals.MaxLaunchAngleAgainst.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MinExitVelocity.IsSet() {
		localVarQueryParams.Add("minExitVelocity", parameterToString(localVarOptionals.MinExitVelocity.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MaxExitVelocity.IsSet() {
		localVarQueryParams.Add("maxExitVelocity", parameterToString(localVarOptionals.MaxExitVelocity.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MinLaunchAngle.IsSet() {
		localVarQueryParams.Add("minLaunchAngle", parameterToString(localVarOptionals.MinLaunchAngle.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MaxLaunchAngle.IsSet() {
		localVarQueryParams.Add("maxLaunchAngle", parameterToString(localVarOptionals.MaxLaunchAngle.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MinHomeRunDistance.IsSet() {
		localVarQueryParams.Add("minHomeRunDistance", parameterToString(localVarOptionals.MinHomeRunDistance.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MaxHomeRunDistance.IsSet() {
		localVarQueryParams.Add("maxHomeRunDistance", parameterToString(localVarOptionals.MaxHomeRunDistance.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MinHitDistance.IsSet() {
		localVarQueryParams.Add("minHitDistance", parameterToString(localVarOptionals.MinHitDistance.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MaxHitDistance.IsSet() {
		localVarQueryParams.Add("maxHitDistance", parameterToString(localVarOptionals.MaxHitDistance.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MinHangTime.IsSet() {
		localVarQueryParams.Add("minHangTime", parameterToString(localVarOptionals.MinHangTime.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MaxHangTime.IsSet() {
		localVarQueryParams.Add("maxHangTime", parameterToString(localVarOptionals.MaxHangTime.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MinHitProbability.IsSet() {
		localVarQueryParams.Add("minHitProbability", parameterToString(localVarOptionals.MinHitProbability.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MaxHitProbability.IsSet() {
		localVarQueryParams.Add("maxHitProbability", parameterToString(localVarOptionals.MaxHitProbability.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MinCatchProbability.IsSet() {
		localVarQueryParams.Add("minCatchProbability", parameterToString(localVarOptionals.MinCatchProbability.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MaxCatchProbability.IsSet() {
		localVarQueryParams.Add("maxCatchProbability", parameterToString(localVarOptionals.MaxCatchProbability.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MinAttackAngle.IsSet() {
		localVarQueryParams.Add("minAttackAngle", parameterToString(localVarOptionals.MinAttackAngle.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MaxAttackAngle.IsSet() {
		localVarQueryParams.Add("maxAttackAngle", parameterToString(localVarOptionals.MaxAttackAngle.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MinBatSpeed.IsSet() {
		localVarQueryParams.Add("minBatSpeed", parameterToString(localVarOptionals.MinBatSpeed.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MaxBatSpeed.IsSet() {
		localVarQueryParams.Add("maxBatSpeed", parameterToString(localVarOptionals.MaxBatSpeed.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MinHomeRunXBallparks.IsSet() {
		localVarQueryParams.Add("minHomeRunXBallparks", parameterToString(localVarOptionals.MinHomeRunXBallparks.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MaxHomeRunXBallparks.IsSet() {
		localVarQueryParams.Add("maxHomeRunXBallparks", parameterToString(localVarOptionals.MaxHomeRunXBallparks.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.IsBarrel.IsSet() {
		localVarQueryParams.Add("isBarrel", parameterToString(localVarOptionals.IsBarrel.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.HitTrajectories.IsSet() {
		localVarQueryParams.Add("hitTrajectories", parameterToString(localVarOptionals.HitTrajectories.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Limit.IsSet() {
		localVarQueryParams.Add("limit", parameterToString(localVarOptionals.Limit.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Offset.IsSet() {
		localVarQueryParams.Add("offset", parameterToString(localVarOptionals.Offset.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.GroupBy.IsSet() {
		localVarQueryParams.Add("groupBy", parameterToString(localVarOptionals.GroupBy.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.CompareOver.IsSet() {
		localVarQueryParams.Add("compareOver", parameterToString(localVarOptionals.CompareOver.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.SortStat.IsSet() {
		localVarQueryParams.Add("sortStat", parameterToString(localVarOptionals.SortStat.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.SortModifier.IsSet() {
		localVarQueryParams.Add("sortModifier", parameterToString(localVarOptionals.SortModifier.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.SortOrder.IsSet() {
		localVarQueryParams.Add("sortOrder", parameterToString(localVarOptionals.SortOrder.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Percentile.IsSet() {
		localVarQueryParams.Add("percentile", parameterToString(localVarOptionals.Percentile.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MinOccurrences.IsSet() {
		localVarQueryParams.Add("minOccurrences", parameterToString(localVarOptionals.MinOccurrences.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MinPlateAppearances.IsSet() {
		localVarQueryParams.Add("minPlateAppearances", parameterToString(localVarOptionals.MinPlateAppearances.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MinInnings.IsSet() {
		localVarQueryParams.Add("minInnings", parameterToString(localVarOptionals.MinInnings.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.QualifierRate.IsSet() {
		localVarQueryParams.Add("qualifierRate", parameterToString(localVarOptionals.QualifierRate.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.SitCodes.IsSet() {
		localVarQueryParams.Add("sitCodes", parameterToString(localVarOptionals.SitCodes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.ShowTotals.IsSet() {
		localVarQueryParams.Add("showTotals", parameterToString(localVarOptionals.ShowTotals.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.IncludeNullMetrics.IsSet() {
		localVarQueryParams.Add("includeNullMetrics", parameterToString(localVarOptionals.IncludeNullMetrics.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.StatFields.IsSet() {
		localVarQueryParams.Add("statFields", parameterToString(localVarOptionals.StatFields.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.AtBatNumbers.IsSet() {
		localVarQueryParams.Add("atBatNumbers", parameterToString(localVarOptionals.AtBatNumbers.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PitchNumbers.IsSet() {
		localVarQueryParams.Add("pitchNumbers", parameterToString(localVarOptionals.PitchNumbers.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Fields.IsSet() {
		localVarQueryParams.Add("fields", parameterToString(localVarOptionals.Fields.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Debug.IsSet() {
		localVarQueryParams.Add("debug", parameterToString(localVarOptionals.Debug.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.ActiveStatus.IsSet() {
		localVarQueryParams.Add("activeStatus", parameterToString(localVarOptionals.ActiveStatus.Value(), ""))
	}
	// to determine the Content-Type header
	localVarHttpContentTypes := []string{}

	// set Content-Type header
	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
	if localVarHttpContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHttpContentType
	}

	// to determine the Accept header
	localVarHttpHeaderAccepts := []string{"*/*"}

	// set Accept header
	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
	if localVarHttpHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
	}
	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
	if err != nil {
		return localVarReturnValue, nil, err
	}

	localVarHttpResponse, err := a.client.callAPI(r)
	if err != nil || localVarHttpResponse == nil {
		return localVarReturnValue, localVarHttpResponse, err
	}

	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
	localVarHttpResponse.Body.Close()
	if err != nil {
		return localVarReturnValue, localVarHttpResponse, err
	}

	if localVarHttpResponse.StatusCode < 300 {
		// If we succeed, return the data, otherwise pass on to decode error.
		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
		if err == nil {
			return localVarReturnValue, localVarHttpResponse, err
		}
	}

	if localVarHttpResponse.StatusCode >= 300 {
		newErr := GenericSwaggerError{
			body:  localVarBody,
			error: localVarHttpResponse.Status,
		}
		if localVarHttpResponse.StatusCode == 200 {
			var v models.StatContainerRestObject
			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHttpResponse, newErr
			}
			newErr.model = v
			return localVarReturnValue, localVarHttpResponse, newErr
		}
		return localVarReturnValue, localVarHttpResponse, newErr
	}

	return localVarReturnValue, localVarHttpResponse, nil
}

/*
StatsApiService Get outs above average for the current batter
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param gamePk
 * @param optional nil or *StatsApiGetOutsAboveAverageOpts - Optional Parameters:
     * @param "Timecode" (optional.String) -
     * @param "Fields" (optional.Interface of []string) -  Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
@return models.StatsRestObject
*/

type StatsApiGetOutsAboveAverageOpts struct {
	Timecode optional.String
	Fields   optional.Interface
}

func (a *StatsApiService) GetOutsAboveAverage(ctx context.Context, gamePk int32, localVarOptionals *StatsApiGetOutsAboveAverageOpts) (models.StatsRestObject, *http.Response, error) {
	var (
		localVarHttpMethod  = strings.ToUpper("Get")
		localVarPostBody    interface{}
		localVarFileName    string
		localVarFileBytes   []byte
		localVarReturnValue models.StatsRestObject
	)

	// create path and map variables
	localVarPath := a.client.cfg.BasePath + "/api/v1/stats/analytics/outsAboveAverage"

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}

	localVarQueryParams.Add("gamePk", parameterToString(gamePk, ""))
	if localVarOptionals != nil && localVarOptionals.Timecode.IsSet() {
		localVarQueryParams.Add("timecode", parameterToString(localVarOptionals.Timecode.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Fields.IsSet() {
		localVarQueryParams.Add("fields", parameterToString(localVarOptionals.Fields.Value(), "multi"))
	}
	// to determine the Content-Type header
	localVarHttpContentTypes := []string{}

	// set Content-Type header
	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
	if localVarHttpContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHttpContentType
	}

	// to determine the Accept header
	localVarHttpHeaderAccepts := []string{"*/*"}

	// set Accept header
	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
	if localVarHttpHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
	}
	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
	if err != nil {
		return localVarReturnValue, nil, err
	}

	localVarHttpResponse, err := a.client.callAPI(r)
	if err != nil || localVarHttpResponse == nil {
		return localVarReturnValue, localVarHttpResponse, err
	}

	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
	localVarHttpResponse.Body.Close()
	if err != nil {
		return localVarReturnValue, localVarHttpResponse, err
	}

	if localVarHttpResponse.StatusCode < 300 {
		// If we succeed, return the data, otherwise pass on to decode error.
		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
		if err == nil {
			return localVarReturnValue, localVarHttpResponse, err
		}
	}

	if localVarHttpResponse.StatusCode >= 300 {
		newErr := GenericSwaggerError{
			body:  localVarBody,
			error: localVarHttpResponse.Status,
		}
		if localVarHttpResponse.StatusCode == 200 {
			var v models.StatsRestObject
			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHttpResponse, newErr
			}
			newErr.model = v
			return localVarReturnValue, localVarHttpResponse, newErr
		}
		return localVarReturnValue, localVarHttpResponse, newErr
	}

	return localVarReturnValue, localVarHttpResponse, nil
}

/*
StatsApiService Get the spray chart info for the current batter
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param gamePk
 * @param optional nil or *StatsApiGetSprayChartOpts - Optional Parameters:
     * @param "Timecode" (optional.String) -
     * @param "Fields" (optional.Interface of []string) -  Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
@return models.StatsRestObject
*/

type StatsApiGetSprayChartOpts struct {
	Timecode optional.String
	Fields   optional.Interface
}

func (a *StatsApiService) GetSprayChart(ctx context.Context, gamePk int32, localVarOptionals *StatsApiGetSprayChartOpts) (models.StatsRestObject, *http.Response, error) {
	var (
		localVarHttpMethod  = strings.ToUpper("Get")
		localVarPostBody    interface{}
		localVarFileName    string
		localVarFileBytes   []byte
		localVarReturnValue models.StatsRestObject
	)

	// create path and map variables
	localVarPath := a.client.cfg.BasePath + "/api/v1/stats/analytics/sprayChart"

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}

	localVarQueryParams.Add("gamePk", parameterToString(gamePk, ""))
	if localVarOptionals != nil && localVarOptionals.Timecode.IsSet() {
		localVarQueryParams.Add("timecode", parameterToString(localVarOptionals.Timecode.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Fields.IsSet() {
		localVarQueryParams.Add("fields", parameterToString(localVarOptionals.Fields.Value(), "multi"))
	}
	// to determine the Content-Type header
	localVarHttpContentTypes := []string{}

	// set Content-Type header
	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
	if localVarHttpContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHttpContentType
	}

	// to determine the Accept header
	localVarHttpHeaderAccepts := []string{"*/*"}

	// set Accept header
	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
	if localVarHttpHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
	}
	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
	if err != nil {
		return localVarReturnValue, nil, err
	}

	localVarHttpResponse, err := a.client.callAPI(r)
	if err != nil || localVarHttpResponse == nil {
		return localVarReturnValue, localVarHttpResponse, err
	}

	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
	localVarHttpResponse.Body.Close()
	if err != nil {
		return localVarReturnValue, localVarHttpResponse, err
	}

	if localVarHttpResponse.StatusCode < 300 {
		// If we succeed, return the data, otherwise pass on to decode error.
		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
		if err == nil {
			return localVarReturnValue, localVarHttpResponse, err
		}
	}

	if localVarHttpResponse.StatusCode >= 300 {
		newErr := GenericSwaggerError{
			body:  localVarBody,
			error: localVarHttpResponse.Status,
		}
		if localVarHttpResponse.StatusCode == 200 {
			var v models.StatsRestObject
			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHttpResponse, newErr
			}
			newErr.model = v
			return localVarReturnValue, localVarHttpResponse, newErr
		}
		return localVarReturnValue, localVarHttpResponse, newErr
	}

	return localVarReturnValue, localVarHttpResponse, nil
}

/*
StatsApiService Get the probability of a hit for the given hit data
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param gamePk
 * @param optional nil or *StatsApiGetStolenBaseProbabilityOpts - Optional Parameters:
     * @param "Timecode" (optional.String) -
@return []int32
*/

type StatsApiGetStolenBaseProbabilityOpts struct {
	Timecode optional.String
}

func (a *StatsApiService) GetStolenBaseProbability(ctx context.Context, gamePk int32, localVarOptionals *StatsApiGetStolenBaseProbabilityOpts) ([]int32, *http.Response, error) {
	var (
		localVarHttpMethod  = strings.ToUpper("Get")
		localVarPostBody    interface{}
		localVarFileName    string
		localVarFileBytes   []byte
		localVarReturnValue []int32
	)

	// create path and map variables
	localVarPath := a.client.cfg.BasePath + "/api/v1/stats/analytics/stolenBaseProbability"

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}

	localVarQueryParams.Add("gamePk", parameterToString(gamePk, ""))
	if localVarOptionals != nil && localVarOptionals.Timecode.IsSet() {
		localVarQueryParams.Add("timecode", parameterToString(localVarOptionals.Timecode.Value(), ""))
	}
	// to determine the Content-Type header
	localVarHttpContentTypes := []string{}

	// set Content-Type header
	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
	if localVarHttpContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHttpContentType
	}

	// to determine the Accept header
	localVarHttpHeaderAccepts := []string{"*/*"}

	// set Accept header
	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
	if localVarHttpHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
	}
	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
	if err != nil {
		return localVarReturnValue, nil, err
	}

	localVarHttpResponse, err := a.client.callAPI(r)
	if err != nil || localVarHttpResponse == nil {
		return localVarReturnValue, localVarHttpResponse, err
	}

	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
	localVarHttpResponse.Body.Close()
	if err != nil {
		return localVarReturnValue, localVarHttpResponse, err
	}

	if localVarHttpResponse.StatusCode < 300 {
		// If we succeed, return the data, otherwise pass on to decode error.
		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
		if err == nil {
			return localVarReturnValue, localVarHttpResponse, err
		}
	}

	if localVarHttpResponse.StatusCode >= 300 {
		newErr := GenericSwaggerError{
			body:  localVarBody,
			error: localVarHttpResponse.Status,
		}
		if localVarHttpResponse.StatusCode == 200 {
			var v []int32
			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHttpResponse, newErr
			}
			newErr.model = v
			return localVarReturnValue, localVarHttpResponse, newErr
		}
		return localVarReturnValue, localVarHttpResponse, newErr
	}

	return localVarReturnValue, localVarHttpResponse, nil
}

/*
StatsApiService View grouped stats
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param stats Type of statistics. Format: Individual, Team, Career, etc. Available types in /api/v1/statTypes
 * @param group Category of statistic to return. Available types in /api/v1/statGroups
 * @param optional nil or *StatsApiGroupedStatsOpts - Optional Parameters:
     * @param "PersonId" (optional.Int32) -  Unique Player Identifier. Format: 434538, 429665, etc
     * @param "TeamId" (optional.Int32) -  Unique Team Identifier. Format: 141, 147, etc
     * @param "TeamIds" (optional.Interface of []int32) -  Comma delimited list of Unique Team identifiers
     * @param "GameType" (optional.Interface of models.GameTypeEnum) -  Type of Game. Available types in /api/v1/gameTypes
     * @param "Season" (optional.String) -  Season of play
     * @param "Seasons" (optional.Interface of []string) -  Comma delimited list of Seasons of play
     * @param "SportId" (optional.Int32) -  Top level organization of a sport
     * @param "SportIds" (optional.Interface of []int32) -  Comma delimited list of top level organizations of a sport
     * @param "LeagueId" (optional.Int32) -  Unique League Identifier
     * @param "LeagueIds" (optional.Interface of []int32) -  Comma delimited list of Unique league identifiers
     * @param "LeagueListId" (optional.Interface of LeagueListsEnum) -  Unique League List Identifier
     * @param "Metrics" (optional.Interface of []MetricType) -  Name of metric(s) for metric log stats.  Available metrics in /api/v1/metrics
     * @param "GamePk" (optional.Int32) -  Unique Primary Key Representing a Game
     * @param "BatterTeamId" (optional.Interface of []int32) -  A unique identifier for the batter&#x27;s team
     * @param "PitcherTeamId" (optional.Interface of []int32) -  A unique identifier for the pitcher&#x27;s team
     * @param "BatterId" (optional.Int32) -  Unique Player Identifier. Format: 434538, 429665, etc
     * @param "PitcherId" (optional.Int32) -  Unique Player Identifier. Format: 434538, 429665, etc
     * @param "SitCodes" (optional.Interface of []string) -  Situation code for a given stat split.
     * @param "CombineSits" (optional.Bool) -  If true, gathers stats where all of the situational criteria are met. If false, returns stats where any of the situational criteria are met. Default: false
     * @param "OpposingTeamId" (optional.Int32) -  A unique identifier for the opposing team. Must be used with Team ID
     * @param "Fields" (optional.Interface of []string) -  Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
     * @param "SortStat" (optional.Interface of BaseballStatsEnum) -  Baseball stat to sort splits by.
     * @param "Order" (optional.Interface of SortOrderEnum) -  The order of sorting, ascending or descending
     * @param "PlayerPool" (optional.Interface of PlayerPoolEnum) -  Return \&quot;ALL\&quot; or only \&quot;QUALIFIED\&quot; players based on plate appearances.
     * @param "Position" (optional.Interface of []models.BaseballPosition) -  Position number. Format: 1, 2, 3, etc
     * @param "StartDate" (optional.String) -  Start date for range of data (must be used with end date). Format: MM/DD/YYYY
     * @param "EndDate" (optional.String) -  End date for range of data (must be used with start date). Format: MM/DD/YYYY
     * @param "DaysBack" (optional.Int32) -  Returns results from the last &#x27;X&#x27; days (Starting from yesterday).
     * @param "GamesBack" (optional.Int32) -  Returns results from the last &#x27;X&#x27; games played.
     * @param "ExcludeTradedPlayers" (optional.Bool) -  Excludes players who have since been traded from the input team
     * @param "Offset" (optional.Int32) -  The pointer to start for a return set; used for pagination
     * @param "Limit" (optional.Int32) -  Number of results to return
     * @param "StatFields" (optional.Interface of []StatField) -  Baseball stat fields to populate
     * @param "SortField" (optional.Interface of StatField) -  Baseball statField to sort on.  If no statField is given, sortField defaults to BASIC.  If 1 statField is given, that is the default sortField.
@return models.StatsRestObject
*/

type StatsApiGroupedStatsOpts struct {
	PersonId             optional.Int32
	TeamId               optional.Int32
	TeamIds              optional.Interface
	GameType             optional.Interface
	Season               optional.String
	Seasons              optional.Interface
	SportId              optional.Int32
	SportIds             optional.Interface
	LeagueId             optional.Int32
	LeagueIds            optional.Interface
	LeagueListId         optional.Interface
	Metrics              optional.Interface
	GamePk               optional.Int32
	BatterTeamId         optional.Interface
	PitcherTeamId        optional.Interface
	BatterId             optional.Int32
	PitcherId            optional.Int32
	SitCodes             optional.Interface
	CombineSits          optional.Bool
	OpposingTeamId       optional.Int32
	Fields               optional.Interface
	SortStat             optional.Interface
	Order                optional.Interface
	PlayerPool           optional.Interface
	Position             optional.Interface
	StartDate            optional.String
	EndDate              optional.String
	DaysBack             optional.Int32
	GamesBack            optional.Int32
	ExcludeTradedPlayers optional.Bool
	Offset               optional.Int32
	Limit                optional.Int32
	StatFields           optional.Interface
	SortField            optional.Interface
}

func (a *StatsApiService) GroupedStats(ctx context.Context, stats []models.StatType, group []models.StatGroup, localVarOptionals *StatsApiGroupedStatsOpts) (models.StatsRestObject, *http.Response, error) {
	var (
		localVarHttpMethod  = strings.ToUpper("Get")
		localVarPostBody    interface{}
		localVarFileName    string
		localVarFileBytes   []byte
		localVarReturnValue models.StatsRestObject
	)

	// create path and map variables
	localVarPath := a.client.cfg.BasePath + "/api/v1/stats/grouped"

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}

	localVarQueryParams.Add("stats", parameterToString(stats, "multi"))
	if localVarOptionals != nil && localVarOptionals.PersonId.IsSet() {
		localVarQueryParams.Add("personId", parameterToString(localVarOptionals.PersonId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.TeamId.IsSet() {
		localVarQueryParams.Add("teamId", parameterToString(localVarOptionals.TeamId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.TeamIds.IsSet() {
		localVarQueryParams.Add("teamIds", parameterToString(localVarOptionals.TeamIds.Value(), "multi"))
	}
	localVarQueryParams.Add("group", parameterToString(group, "multi"))
	if localVarOptionals != nil && localVarOptionals.GameType.IsSet() {
		localVarQueryParams.Add("gameType", parameterToString(localVarOptionals.GameType.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Season.IsSet() {
		localVarQueryParams.Add("season", parameterToString(localVarOptionals.Season.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Seasons.IsSet() {
		localVarQueryParams.Add("seasons", parameterToString(localVarOptionals.Seasons.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.SportId.IsSet() {
		localVarQueryParams.Add("sportId", parameterToString(localVarOptionals.SportId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.SportIds.IsSet() {
		localVarQueryParams.Add("sportIds", parameterToString(localVarOptionals.SportIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.LeagueId.IsSet() {
		localVarQueryParams.Add("leagueId", parameterToString(localVarOptionals.LeagueId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.LeagueIds.IsSet() {
		localVarQueryParams.Add("leagueIds", parameterToString(localVarOptionals.LeagueIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.LeagueListId.IsSet() {
		localVarQueryParams.Add("leagueListId", parameterToString(localVarOptionals.LeagueListId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Metrics.IsSet() {
		localVarQueryParams.Add("metrics", parameterToString(localVarOptionals.Metrics.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.GamePk.IsSet() {
		localVarQueryParams.Add("gamePk", parameterToString(localVarOptionals.GamePk.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.BatterTeamId.IsSet() {
		localVarQueryParams.Add("batterTeamId", parameterToString(localVarOptionals.BatterTeamId.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PitcherTeamId.IsSet() {
		localVarQueryParams.Add("pitcherTeamId", parameterToString(localVarOptionals.PitcherTeamId.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.BatterId.IsSet() {
		localVarQueryParams.Add("batterId", parameterToString(localVarOptionals.BatterId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.PitcherId.IsSet() {
		localVarQueryParams.Add("pitcherId", parameterToString(localVarOptionals.PitcherId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.SitCodes.IsSet() {
		localVarQueryParams.Add("sitCodes", parameterToString(localVarOptionals.SitCodes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.CombineSits.IsSet() {
		localVarQueryParams.Add("combineSits", parameterToString(localVarOptionals.CombineSits.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.OpposingTeamId.IsSet() {
		localVarQueryParams.Add("opposingTeamId", parameterToString(localVarOptionals.OpposingTeamId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Fields.IsSet() {
		localVarQueryParams.Add("fields", parameterToString(localVarOptionals.Fields.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.SortStat.IsSet() {
		localVarQueryParams.Add("sortStat", parameterToString(localVarOptionals.SortStat.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Order.IsSet() {
		localVarQueryParams.Add("order", parameterToString(localVarOptionals.Order.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.PlayerPool.IsSet() {
		localVarQueryParams.Add("playerPool", parameterToString(localVarOptionals.PlayerPool.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Position.IsSet() {
		localVarQueryParams.Add("position", parameterToString(localVarOptionals.Position.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.StartDate.IsSet() {
		localVarQueryParams.Add("startDate", parameterToString(localVarOptionals.StartDate.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.EndDate.IsSet() {
		localVarQueryParams.Add("endDate", parameterToString(localVarOptionals.EndDate.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.DaysBack.IsSet() {
		localVarQueryParams.Add("daysBack", parameterToString(localVarOptionals.DaysBack.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.GamesBack.IsSet() {
		localVarQueryParams.Add("gamesBack", parameterToString(localVarOptionals.GamesBack.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.ExcludeTradedPlayers.IsSet() {
		localVarQueryParams.Add("excludeTradedPlayers", parameterToString(localVarOptionals.ExcludeTradedPlayers.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Offset.IsSet() {
		localVarQueryParams.Add("offset", parameterToString(localVarOptionals.Offset.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Limit.IsSet() {
		localVarQueryParams.Add("limit", parameterToString(localVarOptionals.Limit.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.StatFields.IsSet() {
		localVarQueryParams.Add("statFields", parameterToString(localVarOptionals.StatFields.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.SortField.IsSet() {
		localVarQueryParams.Add("sortField", parameterToString(localVarOptionals.SortField.Value(), ""))
	}
	// to determine the Content-Type header
	localVarHttpContentTypes := []string{}

	// set Content-Type header
	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
	if localVarHttpContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHttpContentType
	}

	// to determine the Accept header
	localVarHttpHeaderAccepts := []string{"*/*"}

	// set Accept header
	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
	if localVarHttpHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
	}
	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
	if err != nil {
		return localVarReturnValue, nil, err
	}

	localVarHttpResponse, err := a.client.callAPI(r)
	if err != nil || localVarHttpResponse == nil {
		return localVarReturnValue, localVarHttpResponse, err
	}

	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
	localVarHttpResponse.Body.Close()
	if err != nil {
		return localVarReturnValue, localVarHttpResponse, err
	}

	if localVarHttpResponse.StatusCode < 300 {
		// If we succeed, return the data, otherwise pass on to decode error.
		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
		if err == nil {
			return localVarReturnValue, localVarHttpResponse, err
		}
	}

	if localVarHttpResponse.StatusCode >= 300 {
		newErr := GenericSwaggerError{
			body:  localVarBody,
			error: localVarHttpResponse.Status,
		}
		if localVarHttpResponse.StatusCode == 200 {
			var v models.StatsRestObject
			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHttpResponse, newErr
			}
			newErr.model = v
			return localVarReturnValue, localVarHttpResponse, newErr
		}
		return localVarReturnValue, localVarHttpResponse, newErr
	}

	return localVarReturnValue, localVarHttpResponse, nil
}

/*
StatsApiService Get leaders for a statistic
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param optional nil or *StatsApiLeaders2Opts - Optional Parameters:
     * @param "LeaderCategories" (optional.Interface of []PersonLeadersEnum) -
     * @param "LeaderGameTypes" (optional.Interface of []models.GameTypeEnum) -
     * @param "StatGroup" (optional.Interface of []StatGroup) -
     * @param "Season" (optional.String) -
     * @param "Expand" (optional.Interface of []ExpandEnum) -
     * @param "SportId" (optional.Int32) -
     * @param "SportIds" (optional.Interface of []int32) -
     * @param "Stats" (optional.Interface of []StatType) -
     * @param "Limit" (optional.Int32) -
     * @param "Offset" (optional.Int32) -
     * @param "TeamId" (optional.Int32) -
     * @param "TeamIds" (optional.Interface of []int32) -
     * @param "LeagueId" (optional.Int32) -
     * @param "LeagueIds" (optional.Interface of []int32) -
     * @param "LeagueListId" (optional.Interface of LeagueListsEnum) -
     * @param "PlayerPool" (optional.Interface of PlayerPoolEnum) -
     * @param "StatType" (optional.Interface of StatType) -
     * @param "PlayerActive" (optional.Interface of PlayerActiveStatusEnum) -
     * @param "Position" (optional.Interface of []models.BaseballPosition) -
     * @param "SitCodes" (optional.Interface of []string) -
     * @param "OpposingTeamId" (optional.Int32) -
     * @param "StartDate" (optional.String) -
     * @param "EndDate" (optional.String) -
     * @param "DaysBack" (optional.Int32) -
     * @param "GamesBack" (optional.Int32) -
     * @param "GroupBy" (optional.Interface of models.GroupByEnum) -
     * @param "Fields" (optional.Interface of []string) -
@return models.LeagueLeaderContainerRestObject
*/

type StatsApiLeaders2Opts struct {
	LeaderCategories optional.Interface
	LeaderGameTypes  optional.Interface
	StatGroup        optional.Interface
	Season           optional.String
	Expand           optional.Interface
	SportId          optional.Int32
	SportIds         optional.Interface
	Stats            optional.Interface
	Limit            optional.Int32
	Offset           optional.Int32
	TeamId           optional.Int32
	TeamIds          optional.Interface
	LeagueId         optional.Int32
	LeagueIds        optional.Interface
	LeagueListId     optional.Interface
	PlayerPool       optional.Interface
	StatType         optional.Interface
	PlayerActive     optional.Interface
	Position         optional.Interface
	SitCodes         optional.Interface
	OpposingTeamId   optional.Int32
	StartDate        optional.String
	EndDate          optional.String
	DaysBack         optional.Int32
	GamesBack        optional.Int32
	GroupBy          optional.Interface
	Fields           optional.Interface
}

func (a *StatsApiService) Leaders2(ctx context.Context, localVarOptionals *StatsApiLeaders2Opts) (models.LeagueLeaderContainerRestObject, *http.Response, error) {
	var (
		localVarHttpMethod  = strings.ToUpper("Get")
		localVarPostBody    interface{}
		localVarFileName    string
		localVarFileBytes   []byte
		localVarReturnValue models.LeagueLeaderContainerRestObject
	)

	// create path and map variables
	localVarPath := a.client.cfg.BasePath + "/api/v1/stats/leaders"

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}

	if localVarOptionals != nil && localVarOptionals.LeaderCategories.IsSet() {
		localVarQueryParams.Add("leaderCategories", parameterToString(localVarOptionals.LeaderCategories.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.LeaderGameTypes.IsSet() {
		localVarQueryParams.Add("leaderGameTypes", parameterToString(localVarOptionals.LeaderGameTypes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.StatGroup.IsSet() {
		localVarQueryParams.Add("statGroup", parameterToString(localVarOptionals.StatGroup.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Season.IsSet() {
		localVarQueryParams.Add("season", parameterToString(localVarOptionals.Season.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Expand.IsSet() {
		localVarQueryParams.Add("expand", parameterToString(localVarOptionals.Expand.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.SportId.IsSet() {
		localVarQueryParams.Add("sportId", parameterToString(localVarOptionals.SportId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.SportIds.IsSet() {
		localVarQueryParams.Add("sportIds", parameterToString(localVarOptionals.SportIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Stats.IsSet() {
		localVarQueryParams.Add("stats", parameterToString(localVarOptionals.Stats.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Limit.IsSet() {
		localVarQueryParams.Add("limit", parameterToString(localVarOptionals.Limit.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Offset.IsSet() {
		localVarQueryParams.Add("offset", parameterToString(localVarOptionals.Offset.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.TeamId.IsSet() {
		localVarQueryParams.Add("teamId", parameterToString(localVarOptionals.TeamId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.TeamIds.IsSet() {
		localVarQueryParams.Add("teamIds", parameterToString(localVarOptionals.TeamIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.LeagueId.IsSet() {
		localVarQueryParams.Add("leagueId", parameterToString(localVarOptionals.LeagueId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.LeagueIds.IsSet() {
		localVarQueryParams.Add("leagueIds", parameterToString(localVarOptionals.LeagueIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.LeagueListId.IsSet() {
		localVarQueryParams.Add("leagueListId", parameterToString(localVarOptionals.LeagueListId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.PlayerPool.IsSet() {
		localVarQueryParams.Add("playerPool", parameterToString(localVarOptionals.PlayerPool.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.StatType.IsSet() {
		localVarQueryParams.Add("statType", parameterToString(localVarOptionals.StatType.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.PlayerActive.IsSet() {
		localVarQueryParams.Add("playerActive", parameterToString(localVarOptionals.PlayerActive.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Position.IsSet() {
		localVarQueryParams.Add("position", parameterToString(localVarOptionals.Position.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.SitCodes.IsSet() {
		localVarQueryParams.Add("sitCodes", parameterToString(localVarOptionals.SitCodes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.OpposingTeamId.IsSet() {
		localVarQueryParams.Add("opposingTeamId", parameterToString(localVarOptionals.OpposingTeamId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.StartDate.IsSet() {
		localVarQueryParams.Add("startDate", parameterToString(localVarOptionals.StartDate.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.EndDate.IsSet() {
		localVarQueryParams.Add("endDate", parameterToString(localVarOptionals.EndDate.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.DaysBack.IsSet() {
		localVarQueryParams.Add("daysBack", parameterToString(localVarOptionals.DaysBack.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.GamesBack.IsSet() {
		localVarQueryParams.Add("gamesBack", parameterToString(localVarOptionals.GamesBack.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.GroupBy.IsSet() {
		localVarQueryParams.Add("groupBy", parameterToString(localVarOptionals.GroupBy.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Fields.IsSet() {
		localVarQueryParams.Add("fields", parameterToString(localVarOptionals.Fields.Value(), "multi"))
	}
	// to determine the Content-Type header
	localVarHttpContentTypes := []string{}

	// set Content-Type header
	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
	if localVarHttpContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHttpContentType
	}

	// to determine the Accept header
	localVarHttpHeaderAccepts := []string{"*/*"}

	// set Accept header
	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
	if localVarHttpHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
	}
	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
	if err != nil {
		return localVarReturnValue, nil, err
	}

	localVarHttpResponse, err := a.client.callAPI(r)
	if err != nil || localVarHttpResponse == nil {
		return localVarReturnValue, localVarHttpResponse, err
	}

	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
	localVarHttpResponse.Body.Close()
	if err != nil {
		return localVarReturnValue, localVarHttpResponse, err
	}

	if localVarHttpResponse.StatusCode < 300 {
		// If we succeed, return the data, otherwise pass on to decode error.
		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
		if err == nil {
			return localVarReturnValue, localVarHttpResponse, err
		}
	}

	if localVarHttpResponse.StatusCode >= 300 {
		newErr := GenericSwaggerError{
			body:  localVarBody,
			error: localVarHttpResponse.Status,
		}
		if localVarHttpResponse.StatusCode == 200 {
			var v models.LeagueLeaderContainerRestObject
			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHttpResponse, newErr
			}
			newErr.model = v
			return localVarReturnValue, localVarHttpResponse, newErr
		}
		return localVarReturnValue, localVarHttpResponse, newErr
	}

	return localVarReturnValue, localVarHttpResponse, nil
}

/*
StatsApiService View metric stats
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param stats Type of statistics. Format: Individual, Team, Career, etc. Available types in /api/v1/statTypes
 * @param metrics Name of metric(s) for metric log stats.  Available metrics in /api/v1/metrics
 * @param optional nil or *StatsApiMetricStatsOpts - Optional Parameters:
     * @param "PersonId" (optional.Int32) -  Unique Player Identifier. Format: 434538, 429665, etc
     * @param "PersonIds" (optional.Interface of []int32) -  Unique Player Identifier. Format: 434538, 429665, etc
     * @param "BatterId" (optional.Int32) -  Unique Player Identifier. Format: 434538, 429665, etc
     * @param "PitcherId" (optional.Int32) -  Unique Player Identifier. Format: 434538, 429665, etc
     * @param "TeamId" (optional.Int32) -  Unique Team Identifier. Format: 141, 147, etc
     * @param "Group" (optional.Interface of []StatGroup) -  Category of statistic to return. Available types in /api/v1/statGroups
     * @param "Season" (optional.String) -  Season of play
     * @param "Seasons" (optional.Interface of []string) -  Comma delimited list of Seasons of play
     * @param "SportId" (optional.Int32) -  Top level organization of a sport
     * @param "OpposingTeamId" (optional.Int32) -  A unique identifier for the opposing team. Must be used with Team ID
     * @param "OpposingPlayerId" (optional.Int32) -  A unique identifier for the opposing team
     * @param "Position" (optional.Interface of []models.BaseballPosition) -  All of the details of a player&#x27;s position
     * @param "EventType" (optional.Interface of []EventType) -  Type of event
     * @param "PitchType" (optional.Interface of []string) -  Classification of pitch (fastball, curveball, etc...)
     * @param "HitTrajectory" (optional.Interface of []HitTrajectory) -  Trajectory of hit (line drive, fly ball, etc...)
     * @param "BatSide" (optional.String) -  Bat side of hitter
     * @param "PitchHand" (optional.String) -  Handedness of pitcher
     * @param "VenueId" (optional.Interface of []int32) -  All of the details of a venue
     * @param "GamePk" (optional.Int32) -  Unique Primary Key Representing a Game
     * @param "MinValue" (optional.Float64) -  Minimum value to filter on
     * @param "MaxValue" (optional.Float64) -  Maximum value to filter on
     * @param "Percentile" (optional.Int32) -  Only return averages above this percentile. used for best effort plays
     * @param "MinOccurrences" (optional.Int32) -  Minimum occurrences to filter upon
     * @param "Offset" (optional.Int32) -  The pointer to start for a return set; used for pagination
     * @param "Limit" (optional.Int32) -  Number of results to return
     * @param "Order" (optional.Interface of SortOrderEnum) -  The order of sorting, ascending or descending
     * @param "Date" (optional.String) -  Date of Game. Format: YYYY-MM-DD
     * @param "StartDate" (optional.String) -  Start date for range of data (must be used with end date). Format: MM/DD/YYYY
     * @param "EndDate" (optional.String) -  End date for range of data (must be used with start date). Format: MM/DD/YYYY
     * @param "GameType" (optional.Interface of models.GameTypeEnum) -  Type of Game. Available types in /api/v1/gameTypes
     * @param "BatterTeamId" (optional.Interface of []int32) -  A unique identifier for the batter&#x27;s team
     * @param "PitcherTeamId" (optional.Interface of []int32) -  A unique identifier for the pitcher&#x27;s team
     * @param "Fields" (optional.Interface of []string) -  Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
     * @param "Debug" (optional.Bool) -
@return models.StatsRestObject
*/

type StatsApiMetricStatsOpts struct {
	PersonId         optional.Int32
	PersonIds        optional.Interface
	BatterId         optional.Int32
	PitcherId        optional.Int32
	TeamId           optional.Int32
	Group            optional.Interface
	Season           optional.String
	Seasons          optional.Interface
	SportId          optional.Int32
	OpposingTeamId   optional.Int32
	OpposingPlayerId optional.Int32
	Position         optional.Interface
	EventType        optional.Interface
	PitchType        optional.Interface
	HitTrajectory    optional.Interface
	BatSide          optional.String
	PitchHand        optional.String
	VenueId          optional.Interface
	GamePk           optional.Int32
	MinValue         optional.Float64
	MaxValue         optional.Float64
	Percentile       optional.Int32
	MinOccurrences   optional.Int32
	Offset           optional.Int32
	Limit            optional.Int32
	Order            optional.Interface
	Date             optional.String
	StartDate        optional.String
	EndDate          optional.String
	GameType         optional.Interface
	BatterTeamId     optional.Interface
	PitcherTeamId    optional.Interface
	Fields           optional.Interface
	Debug            optional.Bool
}

func (a *StatsApiService) MetricStats(ctx context.Context, stats []models.StatType, metrics []models.MetricType, localVarOptionals *StatsApiMetricStatsOpts) (models.StatsRestObject, *http.Response, error) {
	var (
		localVarHttpMethod  = strings.ToUpper("Get")
		localVarPostBody    interface{}
		localVarFileName    string
		localVarFileBytes   []byte
		localVarReturnValue models.StatsRestObject
	)

	// create path and map variables
	localVarPath := a.client.cfg.BasePath + "/api/v1/stats/metrics"

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}

	if localVarOptionals != nil && localVarOptionals.PersonId.IsSet() {
		localVarQueryParams.Add("personId", parameterToString(localVarOptionals.PersonId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.PersonIds.IsSet() {
		localVarQueryParams.Add("personIds", parameterToString(localVarOptionals.PersonIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.BatterId.IsSet() {
		localVarQueryParams.Add("batterId", parameterToString(localVarOptionals.BatterId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.PitcherId.IsSet() {
		localVarQueryParams.Add("pitcherId", parameterToString(localVarOptionals.PitcherId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.TeamId.IsSet() {
		localVarQueryParams.Add("teamId", parameterToString(localVarOptionals.TeamId.Value(), ""))
	}
	localVarQueryParams.Add("stats", parameterToString(stats, "multi"))
	if localVarOptionals != nil && localVarOptionals.Group.IsSet() {
		localVarQueryParams.Add("group", parameterToString(localVarOptionals.Group.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Season.IsSet() {
		localVarQueryParams.Add("season", parameterToString(localVarOptionals.Season.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Seasons.IsSet() {
		localVarQueryParams.Add("seasons", parameterToString(localVarOptionals.Seasons.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.SportId.IsSet() {
		localVarQueryParams.Add("sportId", parameterToString(localVarOptionals.SportId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.OpposingTeamId.IsSet() {
		localVarQueryParams.Add("opposingTeamId", parameterToString(localVarOptionals.OpposingTeamId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.OpposingPlayerId.IsSet() {
		localVarQueryParams.Add("opposingPlayerId", parameterToString(localVarOptionals.OpposingPlayerId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Position.IsSet() {
		localVarQueryParams.Add("position", parameterToString(localVarOptionals.Position.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.EventType.IsSet() {
		localVarQueryParams.Add("eventType", parameterToString(localVarOptionals.EventType.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PitchType.IsSet() {
		localVarQueryParams.Add("pitchType", parameterToString(localVarOptionals.PitchType.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.HitTrajectory.IsSet() {
		localVarQueryParams.Add("hitTrajectory", parameterToString(localVarOptionals.HitTrajectory.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.BatSide.IsSet() {
		localVarQueryParams.Add("batSide", parameterToString(localVarOptionals.BatSide.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.PitchHand.IsSet() {
		localVarQueryParams.Add("pitchHand", parameterToString(localVarOptionals.PitchHand.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.VenueId.IsSet() {
		localVarQueryParams.Add("venueId", parameterToString(localVarOptionals.VenueId.Value(), "multi"))
	}
	localVarQueryParams.Add("metrics", parameterToString(metrics, "multi"))
	if localVarOptionals != nil && localVarOptionals.GamePk.IsSet() {
		localVarQueryParams.Add("gamePk", parameterToString(localVarOptionals.GamePk.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MinValue.IsSet() {
		localVarQueryParams.Add("minValue", parameterToString(localVarOptionals.MinValue.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MaxValue.IsSet() {
		localVarQueryParams.Add("maxValue", parameterToString(localVarOptionals.MaxValue.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Percentile.IsSet() {
		localVarQueryParams.Add("percentile", parameterToString(localVarOptionals.Percentile.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.MinOccurrences.IsSet() {
		localVarQueryParams.Add("minOccurrences", parameterToString(localVarOptionals.MinOccurrences.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Offset.IsSet() {
		localVarQueryParams.Add("offset", parameterToString(localVarOptionals.Offset.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Limit.IsSet() {
		localVarQueryParams.Add("limit", parameterToString(localVarOptionals.Limit.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Order.IsSet() {
		localVarQueryParams.Add("order", parameterToString(localVarOptionals.Order.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Date.IsSet() {
		localVarQueryParams.Add("date", parameterToString(localVarOptionals.Date.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.StartDate.IsSet() {
		localVarQueryParams.Add("startDate", parameterToString(localVarOptionals.StartDate.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.EndDate.IsSet() {
		localVarQueryParams.Add("endDate", parameterToString(localVarOptionals.EndDate.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.GameType.IsSet() {
		localVarQueryParams.Add("gameType", parameterToString(localVarOptionals.GameType.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.BatterTeamId.IsSet() {
		localVarQueryParams.Add("batterTeamId", parameterToString(localVarOptionals.BatterTeamId.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PitcherTeamId.IsSet() {
		localVarQueryParams.Add("pitcherTeamId", parameterToString(localVarOptionals.PitcherTeamId.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Fields.IsSet() {
		localVarQueryParams.Add("fields", parameterToString(localVarOptionals.Fields.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Debug.IsSet() {
		localVarQueryParams.Add("debug", parameterToString(localVarOptionals.Debug.Value(), ""))
	}
	// to determine the Content-Type header
	localVarHttpContentTypes := []string{}

	// set Content-Type header
	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
	if localVarHttpContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHttpContentType
	}

	// to determine the Accept header
	localVarHttpHeaderAccepts := []string{"*/*"}

	// set Accept header
	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
	if localVarHttpHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
	}
	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
	if err != nil {
		return localVarReturnValue, nil, err
	}

	localVarHttpResponse, err := a.client.callAPI(r)
	if err != nil || localVarHttpResponse == nil {
		return localVarReturnValue, localVarHttpResponse, err
	}

	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
	localVarHttpResponse.Body.Close()
	if err != nil {
		return localVarReturnValue, localVarHttpResponse, err
	}

	if localVarHttpResponse.StatusCode < 300 {
		// If we succeed, return the data, otherwise pass on to decode error.
		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
		if err == nil {
			return localVarReturnValue, localVarHttpResponse, err
		}
	}

	if localVarHttpResponse.StatusCode >= 300 {
		newErr := GenericSwaggerError{
			body:  localVarBody,
			error: localVarHttpResponse.Status,
		}
		if localVarHttpResponse.StatusCode == 200 {
			var v models.StatsRestObject
			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHttpResponse, newErr
			}
			newErr.model = v
			return localVarReturnValue, localVarHttpResponse, newErr
		}
		return localVarReturnValue, localVarHttpResponse, newErr
	}

	return localVarReturnValue, localVarHttpResponse, nil
}

/*
StatsApiService View stats
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param stats Type of statistics. Format: Individual, Team, Career, etc. Available types in /api/v1/statTypes
 * @param group Category of statistic to return. Available types in /api/v1/statGroups
 * @param optional nil or *StatsApiStats2Opts - Optional Parameters:
     * @param "PersonId" (optional.Int32) -  Unique Player Identifier. Format: 434538, 429665, etc
     * @param "TeamId" (optional.Int32) -  Unique Team Identifier. Format: 141, 147, etc
     * @param "TeamIds" (optional.Interface of []int32) -  Comma delimited list of Unique Team identifiers
     * @param "GameType" (optional.Interface of models.GameTypeEnum) -  Type of Game. Available types in /api/v1/gameTypes
     * @param "Season" (optional.String) -  Season of play
     * @param "Seasons" (optional.Interface of []string) -  Comma delimited list of Seasons of play
     * @param "SportId" (optional.Int32) -  Top level organization of a sport
     * @param "SportIds" (optional.Interface of []int32) -  Comma delimited list of top level organizations of a sport
     * @param "LeagueId" (optional.Int32) -  Unique League Identifier
     * @param "LeagueIds" (optional.Interface of []int32) -  Comma delimited list of Unique league identifiers
     * @param "LeagueListId" (optional.Interface of LeagueListsEnum) -  Unique League List Identifier
     * @param "Metrics" (optional.Interface of []MetricType) -  Name of metric(s) for metric log stats.  Available metrics in /api/v1/metrics
     * @param "GamePk" (optional.Int32) -  Unique Primary Key Representing a Game
     * @param "BatterTeamId" (optional.Interface of []int32) -  A unique identifier for the batter&#x27;s team
     * @param "PitcherTeamId" (optional.Interface of []int32) -  A unique identifier for the pitcher&#x27;s team
     * @param "BatterId" (optional.Int32) -  Unique Player Identifier. Format: 434538, 429665, etc
     * @param "PitcherId" (optional.Int32) -  Unique Player Identifier. Format: 434538, 429665, etc
     * @param "SitCodes" (optional.Interface of []string) -  Situation code for a given stat split.
     * @param "CombineSits" (optional.Bool) -  If true, gathers stats where all of the situational criteria are met. If false, returns stats where any of the situational criteria are met. Default: false
     * @param "OpposingTeamId" (optional.Int32) -  A unique identifier for the opposing team. Must be used with Team ID
     * @param "Fields" (optional.Interface of []string) -
     * @param "SortStat" (optional.Interface of BaseballStatsEnum) -  Baseball stat to sort splits by.
     * @param "Order" (optional.Interface of SortOrderEnum) -  The order of sorting, ascending or descending
     * @param "PlayerPool" (optional.Interface of PlayerPoolEnum) -  Return \&quot;ALL\&quot; or only \&quot;QUALIFIED\&quot; players based on plate appearances.
     * @param "Position" (optional.Interface of []models.BaseballPosition) -  Position number. Format: 1, 2, 3, etc
     * @param "StartDate" (optional.String) -  Start date for range of data (must be used with end date). Format: MM/DD/YYYY
     * @param "EndDate" (optional.String) -  End date for range of data (must be used with start date). Format: MM/DD/YYYY
     * @param "DaysBack" (optional.Int32) -  Returns results from the last &#x27;X&#x27; days (Starting from yesterday).
     * @param "GamesBack" (optional.Int32) -  Returns results from the last &#x27;X&#x27; games played.
     * @param "ExcludeTradedPlayers" (optional.Bool) -  Excludes players who have since been traded from the input team
     * @param "Offset" (optional.Int32) -  The pointer to start for a return set; used for pagination
     * @param "Limit" (optional.Int32) -  Number of results to return
@return models.StatsRestObject
*/

type StatsApiStats2Opts struct {
	PersonId             optional.Int32
	TeamId               optional.Int32
	TeamIds              optional.Interface
	GameType             optional.Interface
	Season               optional.String
	Seasons              optional.Interface
	SportId              optional.Int32
	SportIds             optional.Interface
	LeagueId             optional.Int32
	LeagueIds            optional.Interface
	LeagueListId         optional.Interface
	Metrics              optional.Interface
	GamePk               optional.Int32
	BatterTeamId         optional.Interface
	PitcherTeamId        optional.Interface
	BatterId             optional.Int32
	PitcherId            optional.Int32
	SitCodes             optional.Interface
	CombineSits          optional.Bool
	OpposingTeamId       optional.Int32
	Fields               optional.Interface
	SortStat             optional.Interface
	Order                optional.Interface
	PlayerPool           optional.Interface
	Position             optional.Interface
	StartDate            optional.String
	EndDate              optional.String
	DaysBack             optional.Int32
	GamesBack            optional.Int32
	ExcludeTradedPlayers optional.Bool
	Offset               optional.Int32
	Limit                optional.Int32
}

func (a *StatsApiService) Stats2(ctx context.Context, stats []models.StatType, group []models.StatGroup, localVarOptionals *StatsApiStats2Opts) (models.StatsRestObject, *http.Response, error) {
	var (
		localVarHttpMethod  = strings.ToUpper("Get")
		localVarPostBody    interface{}
		localVarFileName    string
		localVarFileBytes   []byte
		localVarReturnValue models.StatsRestObject
	)

	// create path and map variables
	localVarPath := a.client.cfg.BasePath + "/api/v1/stats"

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}

	localVarQueryParams.Add("stats", parameterToString(stats, "multi"))
	if localVarOptionals != nil && localVarOptionals.PersonId.IsSet() {
		localVarQueryParams.Add("personId", parameterToString(localVarOptionals.PersonId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.TeamId.IsSet() {
		localVarQueryParams.Add("teamId", parameterToString(localVarOptionals.TeamId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.TeamIds.IsSet() {
		localVarQueryParams.Add("teamIds", parameterToString(localVarOptionals.TeamIds.Value(), "multi"))
	}
	localVarQueryParams.Add("group", parameterToString(group, "multi"))
	if localVarOptionals != nil && localVarOptionals.GameType.IsSet() {
		localVarQueryParams.Add("gameType", parameterToString(localVarOptionals.GameType.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Season.IsSet() {
		localVarQueryParams.Add("season", parameterToString(localVarOptionals.Season.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Seasons.IsSet() {
		localVarQueryParams.Add("seasons", parameterToString(localVarOptionals.Seasons.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.SportId.IsSet() {
		localVarQueryParams.Add("sportId", parameterToString(localVarOptionals.SportId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.SportIds.IsSet() {
		localVarQueryParams.Add("sportIds", parameterToString(localVarOptionals.SportIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.LeagueId.IsSet() {
		localVarQueryParams.Add("leagueId", parameterToString(localVarOptionals.LeagueId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.LeagueIds.IsSet() {
		localVarQueryParams.Add("leagueIds", parameterToString(localVarOptionals.LeagueIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.LeagueListId.IsSet() {
		localVarQueryParams.Add("leagueListId", parameterToString(localVarOptionals.LeagueListId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Metrics.IsSet() {
		localVarQueryParams.Add("metrics", parameterToString(localVarOptionals.Metrics.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.GamePk.IsSet() {
		localVarQueryParams.Add("gamePk", parameterToString(localVarOptionals.GamePk.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.BatterTeamId.IsSet() {
		localVarQueryParams.Add("batterTeamId", parameterToString(localVarOptionals.BatterTeamId.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PitcherTeamId.IsSet() {
		localVarQueryParams.Add("pitcherTeamId", parameterToString(localVarOptionals.PitcherTeamId.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.BatterId.IsSet() {
		localVarQueryParams.Add("batterId", parameterToString(localVarOptionals.BatterId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.PitcherId.IsSet() {
		localVarQueryParams.Add("pitcherId", parameterToString(localVarOptionals.PitcherId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.SitCodes.IsSet() {
		localVarQueryParams.Add("sitCodes", parameterToString(localVarOptionals.SitCodes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.CombineSits.IsSet() {
		localVarQueryParams.Add("combineSits", parameterToString(localVarOptionals.CombineSits.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.OpposingTeamId.IsSet() {
		localVarQueryParams.Add("opposingTeamId", parameterToString(localVarOptionals.OpposingTeamId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Fields.IsSet() {
		localVarQueryParams.Add("fields", parameterToString(localVarOptionals.Fields.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.SortStat.IsSet() {
		localVarQueryParams.Add("sortStat", parameterToString(localVarOptionals.SortStat.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Order.IsSet() {
		localVarQueryParams.Add("order", parameterToString(localVarOptionals.Order.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.PlayerPool.IsSet() {
		localVarQueryParams.Add("playerPool", parameterToString(localVarOptionals.PlayerPool.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Position.IsSet() {
		localVarQueryParams.Add("position", parameterToString(localVarOptionals.Position.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.StartDate.IsSet() {
		localVarQueryParams.Add("startDate", parameterToString(localVarOptionals.StartDate.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.EndDate.IsSet() {
		localVarQueryParams.Add("endDate", parameterToString(localVarOptionals.EndDate.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.DaysBack.IsSet() {
		localVarQueryParams.Add("daysBack", parameterToString(localVarOptionals.DaysBack.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.GamesBack.IsSet() {
		localVarQueryParams.Add("gamesBack", parameterToString(localVarOptionals.GamesBack.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.ExcludeTradedPlayers.IsSet() {
		localVarQueryParams.Add("excludeTradedPlayers", parameterToString(localVarOptionals.ExcludeTradedPlayers.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Offset.IsSet() {
		localVarQueryParams.Add("offset", parameterToString(localVarOptionals.Offset.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Limit.IsSet() {
		localVarQueryParams.Add("limit", parameterToString(localVarOptionals.Limit.Value(), ""))
	}
	// to determine the Content-Type header
	localVarHttpContentTypes := []string{}

	// set Content-Type header
	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
	if localVarHttpContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHttpContentType
	}

	// to determine the Accept header
	localVarHttpHeaderAccepts := []string{"*/*"}

	// set Accept header
	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
	if localVarHttpHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
	}
	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
	if err != nil {
		return localVarReturnValue, nil, err
	}

	localVarHttpResponse, err := a.client.callAPI(r)
	if err != nil || localVarHttpResponse == nil {
		return localVarReturnValue, localVarHttpResponse, err
	}

	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
	localVarHttpResponse.Body.Close()
	if err != nil {
		return localVarReturnValue, localVarHttpResponse, err
	}

	if localVarHttpResponse.StatusCode < 300 {
		// If we succeed, return the data, otherwise pass on to decode error.
		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
		if err == nil {
			return localVarReturnValue, localVarHttpResponse, err
		}
	}

	if localVarHttpResponse.StatusCode >= 300 {
		newErr := GenericSwaggerError{
			body:  localVarBody,
			error: localVarHttpResponse.Status,
		}
		if localVarHttpResponse.StatusCode == 200 {
			var v models.StatsRestObject
			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHttpResponse, newErr
			}
			newErr.model = v
			return localVarReturnValue, localVarHttpResponse, newErr
		}
		return localVarReturnValue, localVarHttpResponse, newErr
	}

	return localVarReturnValue, localVarHttpResponse, nil
}
