/*
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 ScheduleApiService service

/*
ScheduleApiService Get postseason schedule
This endpoint allows you to pull postseason schedules
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param optional nil or *ScheduleApiPostseasonScheduleOpts - Optional Parameters:
     * @param "GameTypes" (optional.Interface of []models.GameTypeEnum) -  Comma delimited list of type of Game. Available types in /api/v1/gameTypes
     * @param "SeriesNumber" (optional.Int32) -
     * @param "TeamId" (optional.Int32) -  Unique Team Identifier. Format: 141, 147, etc
     * @param "SportId" (optional.Int32) -  Unique League Identifier
     * @param "UseLatestGames" (optional.Bool) -
     * @param "UseFeaturedGame" (optional.Bool) -
     * @param "Season" (optional.String) -
     * @param "PublicFacing" (optional.Interface of PublicFacingEnum) -  Return public, non-public or all games. Format: Public Facing &#x3D; &#x27;Y&#x27;, Non-Public Facing &#x3D; &#x27;N&#x27;, All &#x3D; &#x27;A&#x27;
     * @param "Fields" (optional.Interface of []string) -  Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
@return models.ScheduleRestObject
*/

type ScheduleApiPostseasonScheduleOpts struct {
	GameTypes       optional.Interface
	SeriesNumber    optional.Int32
	TeamId          optional.Int32
	SportId         optional.Int32
	UseLatestGames  optional.Bool
	UseFeaturedGame optional.Bool
	Season          optional.String
	PublicFacing    optional.Interface
	Fields          optional.Interface
}

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

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

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

	if localVarOptionals != nil && localVarOptionals.GameTypes.IsSet() {
		localVarQueryParams.Add("gameTypes", parameterToString(localVarOptionals.GameTypes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.SeriesNumber.IsSet() {
		localVarQueryParams.Add("seriesNumber", parameterToString(localVarOptionals.SeriesNumber.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.TeamId.IsSet() {
		localVarQueryParams.Add("teamId", parameterToString(localVarOptionals.TeamId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.SportId.IsSet() {
		localVarQueryParams.Add("sportId", parameterToString(localVarOptionals.SportId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.UseLatestGames.IsSet() {
		localVarQueryParams.Add("useLatestGames", parameterToString(localVarOptionals.UseLatestGames.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.UseFeaturedGame.IsSet() {
		localVarQueryParams.Add("useFeaturedGame", parameterToString(localVarOptionals.UseFeaturedGame.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Season.IsSet() {
		localVarQueryParams.Add("season", parameterToString(localVarOptionals.Season.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.PublicFacing.IsSet() {
		localVarQueryParams.Add("publicFacing", parameterToString(localVarOptionals.PublicFacing.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.ScheduleRestObject
			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
}

/*
ScheduleApiService Get postseason series schedules
This endpoint allows you to pull postseason schedules
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param optional nil or *ScheduleApiPostseasonScheduleSeriesOpts - Optional Parameters:
     * @param "GameTypes" (optional.Interface of []models.GameTypeEnum) -  Comma delimited list of type of Game. Available types in /api/v1/gameTypes
     * @param "SeriesNumber" (optional.Int32) -
     * @param "TeamId" (optional.Int32) -  Unique Team Identifier. Format: 141, 147, etc
     * @param "SportId" (optional.Int32) -  Unique League Identifier
     * @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 "UseLatestGames" (optional.Bool) -
     * @param "UseFeaturedGame" (optional.Bool) -
     * @param "Season" (optional.String) -
     * @param "Fields" (optional.Interface of []string) -  Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
@return PostseasonScheduleRestObject
*/

type ScheduleApiPostseasonScheduleSeriesOpts struct {
	GameTypes       optional.Interface
	SeriesNumber    optional.Int32
	TeamId          optional.Int32
	SportId         optional.Int32
	Date            optional.String
	StartDate       optional.String
	EndDate         optional.String
	UseLatestGames  optional.Bool
	UseFeaturedGame optional.Bool
	Season          optional.String
	Fields          optional.Interface
}

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

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

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

	if localVarOptionals != nil && localVarOptionals.GameTypes.IsSet() {
		localVarQueryParams.Add("gameTypes", parameterToString(localVarOptionals.GameTypes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.SeriesNumber.IsSet() {
		localVarQueryParams.Add("seriesNumber", parameterToString(localVarOptionals.SeriesNumber.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.TeamId.IsSet() {
		localVarQueryParams.Add("teamId", parameterToString(localVarOptionals.TeamId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.SportId.IsSet() {
		localVarQueryParams.Add("sportId", parameterToString(localVarOptionals.SportId.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.UseLatestGames.IsSet() {
		localVarQueryParams.Add("useLatestGames", parameterToString(localVarOptionals.UseLatestGames.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.UseFeaturedGame.IsSet() {
		localVarQueryParams.Add("useFeaturedGame", parameterToString(localVarOptionals.UseFeaturedGame.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Season.IsSet() {
		localVarQueryParams.Add("season", parameterToString(localVarOptionals.Season.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.PostseasonScheduleRestObject
			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
}

/*
ScheduleApiService View schedule info based on scheduleType.
View schedule info. This endpoint allows you to pull schedules
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param usingPrivateEndpoint
 * @param optional nil or *ScheduleApiScheduleOpts - Optional Parameters:
     * @param "CalendarTypes" (optional.Interface of []CalendarTypes) -  Comma delimited list of type of calendar types
     * @param "EventTypes" (optional.Interface of []CalendarTypes) -  Comma delimited list of type of events. &lt;b&gt;Note: Don&#x27;t Use. This will be deprecated in favor of calendarTypes&lt;/b&gt;
     * @param "ScheduleEventTypes" (optional.Interface of []ScheduleEventTypes) -  Comma delimited list of type of event types
     * @param "TeamId" (optional.Interface of []int32) -  Unique Team Identifier. Format: 141, 147, etc
     * @param "LeagueId" (optional.Interface of []int32) -  Unique League Identifier
     * @param "SportId" (optional.Interface of []int32) -  Top level organization of a sport
     * @param "GamePk" (optional.Int32) -  Unique Primary Key Representing a Game
     * @param "GamePks" (optional.Interface of []int32) -  Comma delimited list of unique primary keys
     * @param "EventIds" (optional.Interface of []int32) -  A unique identifier for non-game event
     * @param "VenueIds" (optional.Interface of []int32) -  Unique Venue Identifier
     * @param "PerformerIds" (optional.Interface of []int32) -  A unique identifier for non-team event performers
     * @param "GameTypes" (optional.Interface of []models.GameTypeEnum) -  Comma delimited list of type of Game. Available types in /api/v1/gameTypes
     * @param "GameType" (optional.Interface of []models.GameTypeEnum) -  Type of Game. Available types in /api/v1/gameTypes
     * @param "Season" (optional.Interface of []string) -  Season of play
     * @param "Seasons" (optional.Interface of []string) -  Comma delimited list of Seasons of play
     * @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 "Timecode" (optional.String) -  Use this parameter to return a snapshot of the data at the specified time. Format: YYYYMMDD_HHMMSS
     * @param "UseLatestGames" (optional.Bool) -
     * @param "OpponentId" (optional.Interface of []int32) -  A unique identifier for the opposing team. Must be used with Team ID
     * @param "PublicFacing" (optional.Interface of PublicFacingEnum) -  Return public, non-public or all games. Format: Public Facing &#x3D; &#x27;Y&#x27;, Non-Public Facing &#x3D; &#x27;N&#x27;, All &#x3D; &#x27;A&#x27;
     * @param "Fields" (optional.Interface of []string) -  Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
@return models.ScheduleRestObject
*/

type ScheduleApiScheduleOpts struct {
	CalendarTypes      optional.Interface
	EventTypes         optional.Interface
	ScheduleEventTypes optional.Interface
	TeamId             optional.Interface
	LeagueId           optional.Interface
	SportId            optional.Interface
	GamePk             optional.Int32
	GamePks            optional.Interface
	EventIds           optional.Interface
	VenueIds           optional.Interface
	PerformerIds       optional.Interface
	GameTypes          optional.Interface
	GameType           optional.Interface
	Season             optional.Interface
	Seasons            optional.Interface
	Date               optional.String
	StartDate          optional.String
	EndDate            optional.String
	Timecode           optional.String
	UseLatestGames     optional.Bool
	OpponentId         optional.Interface
	PublicFacing       optional.Interface
	Fields             optional.Interface
}

func (a *ScheduleApiService) Schedule(ctx context.Context, usingPrivateEndpoint bool, localVarOptionals *ScheduleApiScheduleOpts) (models.ScheduleRestObject, *http.Response, error) {
	var (
		localVarHttpMethod  = strings.ToUpper("Get")
		localVarPostBody    interface{}
		localVarFileName    string
		localVarFileBytes   []byte
		localVarReturnValue models.ScheduleRestObject
	)

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

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

	if localVarOptionals != nil && localVarOptionals.CalendarTypes.IsSet() {
		localVarQueryParams.Add("calendarTypes", parameterToString(localVarOptionals.CalendarTypes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.EventTypes.IsSet() {
		localVarQueryParams.Add("eventTypes", parameterToString(localVarOptionals.EventTypes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.ScheduleEventTypes.IsSet() {
		localVarQueryParams.Add("scheduleEventTypes", parameterToString(localVarOptionals.ScheduleEventTypes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.TeamId.IsSet() {
		localVarQueryParams.Add("teamId", parameterToString(localVarOptionals.TeamId.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.LeagueId.IsSet() {
		localVarQueryParams.Add("leagueId", parameterToString(localVarOptionals.LeagueId.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.SportId.IsSet() {
		localVarQueryParams.Add("sportId", parameterToString(localVarOptionals.SportId.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.GamePk.IsSet() {
		localVarQueryParams.Add("gamePk", parameterToString(localVarOptionals.GamePk.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.GamePks.IsSet() {
		localVarQueryParams.Add("gamePks", parameterToString(localVarOptionals.GamePks.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.EventIds.IsSet() {
		localVarQueryParams.Add("eventIds", parameterToString(localVarOptionals.EventIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.VenueIds.IsSet() {
		localVarQueryParams.Add("venueIds", parameterToString(localVarOptionals.VenueIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PerformerIds.IsSet() {
		localVarQueryParams.Add("performerIds", parameterToString(localVarOptionals.PerformerIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.GameTypes.IsSet() {
		localVarQueryParams.Add("gameTypes", parameterToString(localVarOptionals.GameTypes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.GameType.IsSet() {
		localVarQueryParams.Add("gameType", parameterToString(localVarOptionals.GameType.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Season.IsSet() {
		localVarQueryParams.Add("season", parameterToString(localVarOptionals.Season.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Seasons.IsSet() {
		localVarQueryParams.Add("seasons", parameterToString(localVarOptionals.Seasons.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.Timecode.IsSet() {
		localVarQueryParams.Add("timecode", parameterToString(localVarOptionals.Timecode.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.UseLatestGames.IsSet() {
		localVarQueryParams.Add("useLatestGames", parameterToString(localVarOptionals.UseLatestGames.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.OpponentId.IsSet() {
		localVarQueryParams.Add("opponentId", parameterToString(localVarOptionals.OpponentId.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PublicFacing.IsSet() {
		localVarQueryParams.Add("publicFacing", parameterToString(localVarOptionals.PublicFacing.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Fields.IsSet() {
		localVarQueryParams.Add("fields", parameterToString(localVarOptionals.Fields.Value(), "multi"))
	}
	localVarQueryParams.Add("usingPrivateEndpoint", parameterToString(usingPrivateEndpoint, ""))
	// 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.ScheduleRestObject
			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
}

/*
ScheduleApiService View schedule info based on scheduleType.
View schedule info. This endpoint allows you to pull schedules
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param usingPrivateEndpoint
 * @param optional nil or *ScheduleApiSchedule1Opts - Optional Parameters:
     * @param "CalendarTypes" (optional.Interface of []CalendarTypes) -  Comma delimited list of type of calendar types
     * @param "EventTypes" (optional.Interface of []CalendarTypes) -  Comma delimited list of type of events. &lt;b&gt;Note: Don&#x27;t Use. This will be deprecated in favor of calendarTypes&lt;/b&gt;
     * @param "ScheduleEventTypes" (optional.Interface of []ScheduleEventTypes) -  Comma delimited list of type of event types
     * @param "TeamId" (optional.Interface of []int32) -  Unique Team Identifier. Format: 141, 147, etc
     * @param "LeagueId" (optional.Interface of []int32) -  Unique League Identifier
     * @param "SportId" (optional.Interface of []int32) -  Top level organization of a sport
     * @param "GamePk" (optional.Int32) -  Unique Primary Key Representing a Game
     * @param "GamePks" (optional.Interface of []int32) -  Comma delimited list of unique primary keys
     * @param "EventIds" (optional.Interface of []int32) -  A unique identifier for non-game event
     * @param "VenueIds" (optional.Interface of []int32) -  Unique Venue Identifier
     * @param "PerformerIds" (optional.Interface of []int32) -  A unique identifier for non-team event performers
     * @param "GameTypes" (optional.Interface of []models.GameTypeEnum) -  Comma delimited list of type of Game. Available types in /api/v1/gameTypes
     * @param "GameType" (optional.Interface of []models.GameTypeEnum) -  Type of Game. Available types in /api/v1/gameTypes
     * @param "Season" (optional.Interface of []string) -  Season of play
     * @param "Seasons" (optional.Interface of []string) -  Comma delimited list of Seasons of play
     * @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 "Timecode" (optional.String) -  Use this parameter to return a snapshot of the data at the specified time. Format: YYYYMMDD_HHMMSS
     * @param "UseLatestGames" (optional.Bool) -
     * @param "OpponentId" (optional.Interface of []int32) -  A unique identifier for the opposing team. Must be used with Team ID
     * @param "PublicFacing" (optional.Interface of PublicFacingEnum) -  Return public, non-public or all games. Format: Public Facing &#x3D; &#x27;Y&#x27;, Non-Public Facing &#x3D; &#x27;N&#x27;, All &#x3D; &#x27;A&#x27;
     * @param "Fields" (optional.Interface of []string) -  Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
@return models.ScheduleRestObject
*/

type ScheduleApiSchedule1Opts struct {
	CalendarTypes      optional.Interface
	EventTypes         optional.Interface
	ScheduleEventTypes optional.Interface
	TeamId             optional.Interface
	LeagueId           optional.Interface
	SportId            optional.Interface
	GamePk             optional.Int32
	GamePks            optional.Interface
	EventIds           optional.Interface
	VenueIds           optional.Interface
	PerformerIds       optional.Interface
	GameTypes          optional.Interface
	GameType           optional.Interface
	Season             optional.Interface
	Seasons            optional.Interface
	Date               optional.String
	StartDate          optional.String
	EndDate            optional.String
	Timecode           optional.String
	UseLatestGames     optional.Bool
	OpponentId         optional.Interface
	PublicFacing       optional.Interface
	Fields             optional.Interface
}

func (a *ScheduleApiService) Schedule1(ctx context.Context, usingPrivateEndpoint bool, localVarOptionals *ScheduleApiSchedule1Opts) (models.ScheduleRestObject, *http.Response, error) {
	var (
		localVarHttpMethod  = strings.ToUpper("Get")
		localVarPostBody    interface{}
		localVarFileName    string
		localVarFileBytes   []byte
		localVarReturnValue models.ScheduleRestObject
	)

	// create path and map variables
	localVarPath := a.client.cfg.BasePath + "/api/v1/schedule/{scheduleType}"

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

	if localVarOptionals != nil && localVarOptionals.CalendarTypes.IsSet() {
		localVarQueryParams.Add("calendarTypes", parameterToString(localVarOptionals.CalendarTypes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.EventTypes.IsSet() {
		localVarQueryParams.Add("eventTypes", parameterToString(localVarOptionals.EventTypes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.ScheduleEventTypes.IsSet() {
		localVarQueryParams.Add("scheduleEventTypes", parameterToString(localVarOptionals.ScheduleEventTypes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.TeamId.IsSet() {
		localVarQueryParams.Add("teamId", parameterToString(localVarOptionals.TeamId.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.LeagueId.IsSet() {
		localVarQueryParams.Add("leagueId", parameterToString(localVarOptionals.LeagueId.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.SportId.IsSet() {
		localVarQueryParams.Add("sportId", parameterToString(localVarOptionals.SportId.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.GamePk.IsSet() {
		localVarQueryParams.Add("gamePk", parameterToString(localVarOptionals.GamePk.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.GamePks.IsSet() {
		localVarQueryParams.Add("gamePks", parameterToString(localVarOptionals.GamePks.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.EventIds.IsSet() {
		localVarQueryParams.Add("eventIds", parameterToString(localVarOptionals.EventIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.VenueIds.IsSet() {
		localVarQueryParams.Add("venueIds", parameterToString(localVarOptionals.VenueIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PerformerIds.IsSet() {
		localVarQueryParams.Add("performerIds", parameterToString(localVarOptionals.PerformerIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.GameTypes.IsSet() {
		localVarQueryParams.Add("gameTypes", parameterToString(localVarOptionals.GameTypes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.GameType.IsSet() {
		localVarQueryParams.Add("gameType", parameterToString(localVarOptionals.GameType.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Season.IsSet() {
		localVarQueryParams.Add("season", parameterToString(localVarOptionals.Season.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Seasons.IsSet() {
		localVarQueryParams.Add("seasons", parameterToString(localVarOptionals.Seasons.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.Timecode.IsSet() {
		localVarQueryParams.Add("timecode", parameterToString(localVarOptionals.Timecode.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.UseLatestGames.IsSet() {
		localVarQueryParams.Add("useLatestGames", parameterToString(localVarOptionals.UseLatestGames.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.OpponentId.IsSet() {
		localVarQueryParams.Add("opponentId", parameterToString(localVarOptionals.OpponentId.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PublicFacing.IsSet() {
		localVarQueryParams.Add("publicFacing", parameterToString(localVarOptionals.PublicFacing.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Fields.IsSet() {
		localVarQueryParams.Add("fields", parameterToString(localVarOptionals.Fields.Value(), "multi"))
	}
	localVarQueryParams.Add("usingPrivateEndpoint", parameterToString(usingPrivateEndpoint, ""))
	// 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.ScheduleRestObject
			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
}

/*
ScheduleApiService Get tied game schedules
This endpoint allows you to pull tie game schedules for the given season
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param season Season of play
 * @param optional nil or *ScheduleApiTieGamesOpts - Optional Parameters:
     * @param "SportId" (optional.Interface of []int32) -  Top level organization of a sport
     * @param "GameTypes" (optional.Interface of []models.GameTypeEnum) -  Comma delimited list of type of Game. Available types in /api/v1/gameTypes
     * @param "Fields" (optional.Interface of []string) -  Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
@return models.ScheduleRestObject
*/

type ScheduleApiTieGamesOpts struct {
	SportId   optional.Interface
	GameTypes optional.Interface
	Fields    optional.Interface
}

func (a *ScheduleApiService) TieGames(ctx context.Context, season string, localVarOptionals *ScheduleApiTieGamesOpts) (models.ScheduleRestObject, *http.Response, error) {
	var (
		localVarHttpMethod  = strings.ToUpper("Get")
		localVarPostBody    interface{}
		localVarFileName    string
		localVarFileBytes   []byte
		localVarReturnValue models.ScheduleRestObject
	)

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

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

	if localVarOptionals != nil && localVarOptionals.SportId.IsSet() {
		localVarQueryParams.Add("sportId", parameterToString(localVarOptionals.SportId.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.GameTypes.IsSet() {
		localVarQueryParams.Add("gameTypes", parameterToString(localVarOptionals.GameTypes.Value(), "multi"))
	}
	localVarQueryParams.Add("season", parameterToString(season, ""))
	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.ScheduleRestObject
			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
}

/*
ScheduleApiService Get tracking event schedules
This endpoint allows you to pull schedules for tracking events
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param optional nil or *ScheduleApiTrackingEventsScheduleOpts - Optional Parameters:
     * @param "CalendarTypes" (optional.Interface of []CalendarTypes) -  Comma delimited list of type of calendar types
     * @param "EventTypes" (optional.Interface of []CalendarTypes) -  Comma delimited list of type of events. &lt;b&gt;Note: Don&#x27;t Use. This will be deprecated in favor of calendarTypes&lt;/b&gt;
     * @param "TeamId" (optional.Interface of []int32) -  Unique Team Identifier. Format: 141, 147, etc
     * @param "LeagueId" (optional.Interface of []int32) -  Unique League Identifier
     * @param "SportId" (optional.Interface of []int32) -  Top level organization of a sport
     * @param "GamePk" (optional.Int32) -  Unique Primary Key Representing a Game
     * @param "GamePks" (optional.Interface of []int32) -  Comma delimited list of unique primary keys
     * @param "EventIds" (optional.Interface of []int32) -  A unique identifier for non-game event
     * @param "VenueIds" (optional.Interface of []int32) -  Unique Venue Identifier
     * @param "PerformerIds" (optional.Interface of []int32) -  A unique identifier for non-team event performers
     * @param "GameTypes" (optional.Interface of []models.GameTypeEnum) -  Comma delimited list of type of Game. Available types in /api/v1/gameTypes
     * @param "GameType" (optional.Interface of []models.GameTypeEnum) -  Type of Game. Available types in /api/v1/gameTypes
     * @param "Season" (optional.Interface of []string) -  Season of play
     * @param "Seasons" (optional.Interface of []string) -  Comma delimited list of Seasons of play
     * @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 "Timecode" (optional.String) -  Use this parameter to return a snapshot of the data at the specified time. Format: YYYYMMDD_HHMMSS
     * @param "UseLatestGames" (optional.Bool) -
     * @param "OpponentId" (optional.Interface of []int32) -  A unique identifier for the opposing team. Must be used with Team ID
     * @param "PublicFacing" (optional.Interface of PublicFacingEnum) -  Return public, non-public or all games. Format: Public Facing &#x3D; &#x27;Y&#x27;, Non-Public Facing &#x3D; &#x27;N&#x27;, All &#x3D; &#x27;A&#x27;
     * @param "Fields" (optional.Interface of []string) -  Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
@return models.ScheduleRestObject
*/

type ScheduleApiTrackingEventsScheduleOpts struct {
	CalendarTypes  optional.Interface
	EventTypes     optional.Interface
	TeamId         optional.Interface
	LeagueId       optional.Interface
	SportId        optional.Interface
	GamePk         optional.Int32
	GamePks        optional.Interface
	EventIds       optional.Interface
	VenueIds       optional.Interface
	PerformerIds   optional.Interface
	GameTypes      optional.Interface
	GameType       optional.Interface
	Season         optional.Interface
	Seasons        optional.Interface
	Date           optional.String
	StartDate      optional.String
	EndDate        optional.String
	Timecode       optional.String
	UseLatestGames optional.Bool
	OpponentId     optional.Interface
	PublicFacing   optional.Interface
	Fields         optional.Interface
}

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

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

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

	if localVarOptionals != nil && localVarOptionals.CalendarTypes.IsSet() {
		localVarQueryParams.Add("calendarTypes", parameterToString(localVarOptionals.CalendarTypes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.EventTypes.IsSet() {
		localVarQueryParams.Add("eventTypes", parameterToString(localVarOptionals.EventTypes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.TeamId.IsSet() {
		localVarQueryParams.Add("teamId", parameterToString(localVarOptionals.TeamId.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.LeagueId.IsSet() {
		localVarQueryParams.Add("leagueId", parameterToString(localVarOptionals.LeagueId.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.SportId.IsSet() {
		localVarQueryParams.Add("sportId", parameterToString(localVarOptionals.SportId.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.GamePk.IsSet() {
		localVarQueryParams.Add("gamePk", parameterToString(localVarOptionals.GamePk.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.GamePks.IsSet() {
		localVarQueryParams.Add("gamePks", parameterToString(localVarOptionals.GamePks.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.EventIds.IsSet() {
		localVarQueryParams.Add("eventIds", parameterToString(localVarOptionals.EventIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.VenueIds.IsSet() {
		localVarQueryParams.Add("venueIds", parameterToString(localVarOptionals.VenueIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PerformerIds.IsSet() {
		localVarQueryParams.Add("performerIds", parameterToString(localVarOptionals.PerformerIds.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.GameTypes.IsSet() {
		localVarQueryParams.Add("gameTypes", parameterToString(localVarOptionals.GameTypes.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.GameType.IsSet() {
		localVarQueryParams.Add("gameType", parameterToString(localVarOptionals.GameType.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Season.IsSet() {
		localVarQueryParams.Add("season", parameterToString(localVarOptionals.Season.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Seasons.IsSet() {
		localVarQueryParams.Add("seasons", parameterToString(localVarOptionals.Seasons.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.Timecode.IsSet() {
		localVarQueryParams.Add("timecode", parameterToString(localVarOptionals.Timecode.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.UseLatestGames.IsSet() {
		localVarQueryParams.Add("useLatestGames", parameterToString(localVarOptionals.UseLatestGames.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.OpponentId.IsSet() {
		localVarQueryParams.Add("opponentId", parameterToString(localVarOptionals.OpponentId.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.PublicFacing.IsSet() {
		localVarQueryParams.Add("publicFacing", parameterToString(localVarOptionals.PublicFacing.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.ScheduleRestObject
			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
}

/*
ScheduleApiService Get postseason TuneIn schedules
This endpoint allows you to pull postseason schedules
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param optional nil or *ScheduleApiTuneInOpts - Optional Parameters:
     * @param "TeamId" (optional.Int32) -  Unique Team Identifier. Format: 141, 147, etc
     * @param "SportId" (optional.Int32) -  Unique League Identifier
     * @param "Season" (optional.String) -  Unique Primary Key Representing a Game
     * @param "Fields" (optional.Interface of []string) -  Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
@return models.ScheduleRestObject
*/

type ScheduleApiTuneInOpts struct {
	TeamId  optional.Int32
	SportId optional.Int32
	Season  optional.String
	Fields  optional.Interface
}

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

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

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

	if localVarOptionals != nil && localVarOptionals.TeamId.IsSet() {
		localVarQueryParams.Add("teamId", parameterToString(localVarOptionals.TeamId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.SportId.IsSet() {
		localVarQueryParams.Add("sportId", parameterToString(localVarOptionals.SportId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Season.IsSet() {
		localVarQueryParams.Add("season", parameterToString(localVarOptionals.Season.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.ScheduleRestObject
			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
}
