/*
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"
	"fmt"
	"github.com/antihax/optional"
	"io/ioutil"
	"net/http"
	"net/url"
	"scm.dairydemon.net/filifa/mlbstats/api/models"
	"strings"
)

// Linger please
var (
	_ context.Context
)

type DraftApiService service

/*
DraftApiService View MLB Drafted Players
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param year Year the player was drafted. Format: 2000
 * @param optional nil or *DraftApiDraftPicksOpts - Optional Parameters:
     * @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 "Fields" (optional.Interface of []string) -  Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
     * @param "Order" (optional.Interface of SortOrderEnum) -  The order of sorting, ascending or descending
     * @param "SortBy" (optional.String) -  Sort the set of data by the specified field
     * @param "Drafted" (optional.Bool) -  Whether or not the players been drafted
     * @param "Round" (optional.String) -  Round in which a player was drafted
     * @param "Name" (optional.String) -  Filter players by the first letter of their name using using the specific character
     * @param "School" (optional.String) -  Filter players by the first letter of their school using using the specific character
     * @param "Position" (optional.Interface of models.BaseballPosition) -  Position number. Format: 1, 2, 3, etc
     * @param "Team" (optional.String) -  Unique Team Code. Format: tor, nya, etc
     * @param "TeamId" (optional.Int32) -  Unique Team Identifier. Format: 141, 147, etc
     * @param "State" (optional.String) -  State where the venue is located. Format: Ohio
     * @param "Country" (optional.String) -  Filter players by their home country
     * @param "PlayerId" (optional.Int32) -  A unique identifier for a player
     * @param "BisPlayerId" (optional.Int32) -  A unique identifier for a player in the EBIS system
@return models.BaseballDraftListRestObject
*/

type DraftApiDraftPicksOpts struct {
	Limit       optional.Int32
	Offset      optional.Int32
	Fields      optional.Interface
	Order       optional.Interface
	SortBy      optional.String
	Drafted     optional.Bool
	Round       optional.String
	Name        optional.String
	School      optional.String
	Position    optional.Interface
	Team        optional.String
	TeamId      optional.Int32
	State       optional.String
	Country     optional.String
	PlayerId    optional.Int32
	BisPlayerId optional.Int32
}

func (a *DraftApiService) DraftPicks(ctx context.Context, year int32, localVarOptionals *DraftApiDraftPicksOpts) (models.BaseballDraftListRestObject, *http.Response, error) {
	var (
		localVarHttpMethod  = strings.ToUpper("Get")
		localVarPostBody    interface{}
		localVarFileName    string
		localVarFileBytes   []byte
		localVarReturnValue models.BaseballDraftListRestObject
	)

	// create path and map variables
	localVarPath := a.client.cfg.BasePath + "/api/v1/draft"
	localVarPath = strings.Replace(localVarPath, "{"+"year"+"}", fmt.Sprintf("%v", year), -1)

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

	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.Fields.IsSet() {
		localVarQueryParams.Add("fields", parameterToString(localVarOptionals.Fields.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Order.IsSet() {
		localVarQueryParams.Add("order", parameterToString(localVarOptionals.Order.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.SortBy.IsSet() {
		localVarQueryParams.Add("sortBy", parameterToString(localVarOptionals.SortBy.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Drafted.IsSet() {
		localVarQueryParams.Add("drafted", parameterToString(localVarOptionals.Drafted.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Round.IsSet() {
		localVarQueryParams.Add("round", parameterToString(localVarOptionals.Round.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Name.IsSet() {
		localVarQueryParams.Add("name", parameterToString(localVarOptionals.Name.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.School.IsSet() {
		localVarQueryParams.Add("school", parameterToString(localVarOptionals.School.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Position.IsSet() {
		localVarQueryParams.Add("position", parameterToString(localVarOptionals.Position.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Team.IsSet() {
		localVarQueryParams.Add("team", parameterToString(localVarOptionals.Team.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.TeamId.IsSet() {
		localVarQueryParams.Add("teamId", parameterToString(localVarOptionals.TeamId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.State.IsSet() {
		localVarQueryParams.Add("state", parameterToString(localVarOptionals.State.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Country.IsSet() {
		localVarQueryParams.Add("country", parameterToString(localVarOptionals.Country.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.PlayerId.IsSet() {
		localVarQueryParams.Add("playerId", parameterToString(localVarOptionals.PlayerId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.BisPlayerId.IsSet() {
		localVarQueryParams.Add("bisPlayerId", parameterToString(localVarOptionals.BisPlayerId.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.BaseballDraftListRestObject
			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
}

/*
DraftApiService View MLB Drafted Players
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param year Year the player was drafted. Format: 2000
 * @param optional nil or *DraftApiDraftPicks1Opts - Optional Parameters:
     * @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 "Fields" (optional.Interface of []string) -  Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
     * @param "Order" (optional.Interface of SortOrderEnum) -  The order of sorting, ascending or descending
     * @param "SortBy" (optional.String) -  Sort the set of data by the specified field
     * @param "Drafted" (optional.Bool) -  Whether or not the players been drafted
     * @param "Round" (optional.String) -  Round in which a player was drafted
     * @param "Name" (optional.String) -  Filter players by the first letter of their name using using the specific character
     * @param "School" (optional.String) -  Filter players by the first letter of their school using using the specific character
     * @param "Position" (optional.Interface of models.BaseballPosition) -  Position number. Format: 1, 2, 3, etc
     * @param "Team" (optional.String) -  Unique Team Code. Format: tor, nya, etc
     * @param "TeamId" (optional.Int32) -  Unique Team Identifier. Format: 141, 147, etc
     * @param "State" (optional.String) -  State where the venue is located. Format: Ohio
     * @param "Country" (optional.String) -  Filter players by their home country
     * @param "PlayerId" (optional.Int32) -  A unique identifier for a player
     * @param "BisPlayerId" (optional.Int32) -  A unique identifier for a player in the EBIS system
@return models.BaseballDraftListRestObject
*/

type DraftApiDraftPicks1Opts struct {
	Limit       optional.Int32
	Offset      optional.Int32
	Fields      optional.Interface
	Order       optional.Interface
	SortBy      optional.String
	Drafted     optional.Bool
	Round       optional.String
	Name        optional.String
	School      optional.String
	Position    optional.Interface
	Team        optional.String
	TeamId      optional.Int32
	State       optional.String
	Country     optional.String
	PlayerId    optional.Int32
	BisPlayerId optional.Int32
}

func (a *DraftApiService) DraftPicks1(ctx context.Context, year int32, localVarOptionals *DraftApiDraftPicks1Opts) (models.BaseballDraftListRestObject, *http.Response, error) {
	var (
		localVarHttpMethod  = strings.ToUpper("Get")
		localVarPostBody    interface{}
		localVarFileName    string
		localVarFileBytes   []byte
		localVarReturnValue models.BaseballDraftListRestObject
	)

	// create path and map variables
	localVarPath := a.client.cfg.BasePath + "/api/v1/draft/{year}"
	localVarPath = strings.Replace(localVarPath, "{"+"year"+"}", fmt.Sprintf("%v", year), -1)

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

	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.Fields.IsSet() {
		localVarQueryParams.Add("fields", parameterToString(localVarOptionals.Fields.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Order.IsSet() {
		localVarQueryParams.Add("order", parameterToString(localVarOptionals.Order.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.SortBy.IsSet() {
		localVarQueryParams.Add("sortBy", parameterToString(localVarOptionals.SortBy.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Drafted.IsSet() {
		localVarQueryParams.Add("drafted", parameterToString(localVarOptionals.Drafted.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Round.IsSet() {
		localVarQueryParams.Add("round", parameterToString(localVarOptionals.Round.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Name.IsSet() {
		localVarQueryParams.Add("name", parameterToString(localVarOptionals.Name.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.School.IsSet() {
		localVarQueryParams.Add("school", parameterToString(localVarOptionals.School.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Position.IsSet() {
		localVarQueryParams.Add("position", parameterToString(localVarOptionals.Position.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Team.IsSet() {
		localVarQueryParams.Add("team", parameterToString(localVarOptionals.Team.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.TeamId.IsSet() {
		localVarQueryParams.Add("teamId", parameterToString(localVarOptionals.TeamId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.State.IsSet() {
		localVarQueryParams.Add("state", parameterToString(localVarOptionals.State.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Country.IsSet() {
		localVarQueryParams.Add("country", parameterToString(localVarOptionals.Country.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.PlayerId.IsSet() {
		localVarQueryParams.Add("playerId", parameterToString(localVarOptionals.PlayerId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.BisPlayerId.IsSet() {
		localVarQueryParams.Add("bisPlayerId", parameterToString(localVarOptionals.BisPlayerId.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.BaseballDraftListRestObject
			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
}

/*
DraftApiService View MLB Draft Prospects
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param year Year the player was drafted. Format: 2000
 * @param optional nil or *DraftApiDraftProspectsOpts - Optional Parameters:
     * @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 "Fields" (optional.Interface of []string) -  Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
     * @param "Order" (optional.Interface of SortOrderEnum) -  The order of sorting, ascending or descending
     * @param "SortBy" (optional.String) -  Sort the set of data by the specified field
     * @param "Drafted" (optional.Bool) -  Whether or not the players been drafted
     * @param "Round" (optional.String) -  Round in which a player was drafted
     * @param "Name" (optional.String) -  Filter players by the first letter of their name using using the specific character
     * @param "School" (optional.String) -  Filter players by the first letter of their school using using the specific character
     * @param "Position" (optional.Interface of models.BaseballPosition) -  Position number. Format: 1, 2, 3, etc
     * @param "Team" (optional.String) -  Unique Team Code. Format: tor, nya, etc
     * @param "TeamId" (optional.Int32) -  Unique Team Identifier. Format: 141, 147, etc
     * @param "State" (optional.String) -  State where the venue is located. Format: Ohio
     * @param "Country" (optional.String) -  Filter players by their home country
     * @param "PlayerId" (optional.Int32) -  A unique identifier for a player
     * @param "BisPlayerId" (optional.Int32) -  A unique identifier for a player in the EBIS system
@return models.ProspectListRestObject
*/

type DraftApiDraftProspectsOpts struct {
	Limit       optional.Int32
	Offset      optional.Int32
	Fields      optional.Interface
	Order       optional.Interface
	SortBy      optional.String
	Drafted     optional.Bool
	Round       optional.String
	Name        optional.String
	School      optional.String
	Position    optional.Interface
	Team        optional.String
	TeamId      optional.Int32
	State       optional.String
	Country     optional.String
	PlayerId    optional.Int32
	BisPlayerId optional.Int32
}

func (a *DraftApiService) DraftProspects(ctx context.Context, year int32, localVarOptionals *DraftApiDraftProspectsOpts) (models.ProspectListRestObject, *http.Response, error) {
	var (
		localVarHttpMethod  = strings.ToUpper("Get")
		localVarPostBody    interface{}
		localVarFileName    string
		localVarFileBytes   []byte
		localVarReturnValue models.ProspectListRestObject
	)

	// create path and map variables
	localVarPath := a.client.cfg.BasePath + "/api/v1/draft/prospects"
	localVarPath = strings.Replace(localVarPath, "{"+"year"+"}", fmt.Sprintf("%v", year), -1)

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

	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.Fields.IsSet() {
		localVarQueryParams.Add("fields", parameterToString(localVarOptionals.Fields.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Order.IsSet() {
		localVarQueryParams.Add("order", parameterToString(localVarOptionals.Order.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.SortBy.IsSet() {
		localVarQueryParams.Add("sortBy", parameterToString(localVarOptionals.SortBy.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Drafted.IsSet() {
		localVarQueryParams.Add("drafted", parameterToString(localVarOptionals.Drafted.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Round.IsSet() {
		localVarQueryParams.Add("round", parameterToString(localVarOptionals.Round.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Name.IsSet() {
		localVarQueryParams.Add("name", parameterToString(localVarOptionals.Name.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.School.IsSet() {
		localVarQueryParams.Add("school", parameterToString(localVarOptionals.School.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Position.IsSet() {
		localVarQueryParams.Add("position", parameterToString(localVarOptionals.Position.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Team.IsSet() {
		localVarQueryParams.Add("team", parameterToString(localVarOptionals.Team.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.TeamId.IsSet() {
		localVarQueryParams.Add("teamId", parameterToString(localVarOptionals.TeamId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.State.IsSet() {
		localVarQueryParams.Add("state", parameterToString(localVarOptionals.State.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Country.IsSet() {
		localVarQueryParams.Add("country", parameterToString(localVarOptionals.Country.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.PlayerId.IsSet() {
		localVarQueryParams.Add("playerId", parameterToString(localVarOptionals.PlayerId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.BisPlayerId.IsSet() {
		localVarQueryParams.Add("bisPlayerId", parameterToString(localVarOptionals.BisPlayerId.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.ProspectListRestObject
			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
}

/*
DraftApiService View MLB Draft Prospects
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param year Year the player was drafted. Format: 2000
 * @param optional nil or *DraftApiDraftProspects1Opts - Optional Parameters:
     * @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 "Fields" (optional.Interface of []string) -  Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
     * @param "Order" (optional.Interface of SortOrderEnum) -  The order of sorting, ascending or descending
     * @param "SortBy" (optional.String) -  Sort the set of data by the specified field
     * @param "Drafted" (optional.Bool) -  Whether or not the players been drafted
     * @param "Round" (optional.String) -  Round in which a player was drafted
     * @param "Name" (optional.String) -  Filter players by the first letter of their name using using the specific character
     * @param "School" (optional.String) -  Filter players by the first letter of their school using using the specific character
     * @param "Position" (optional.Interface of models.BaseballPosition) -  Position number. Format: 1, 2, 3, etc
     * @param "Team" (optional.String) -  Unique Team Code. Format: tor, nya, etc
     * @param "TeamId" (optional.Int32) -  Unique Team Identifier. Format: 141, 147, etc
     * @param "State" (optional.String) -  State where the venue is located. Format: Ohio
     * @param "Country" (optional.String) -  Filter players by their home country
     * @param "PlayerId" (optional.Int32) -  A unique identifier for a player
     * @param "BisPlayerId" (optional.Int32) -  A unique identifier for a player in the EBIS system
@return models.ProspectListRestObject
*/

type DraftApiDraftProspects1Opts struct {
	Limit       optional.Int32
	Offset      optional.Int32
	Fields      optional.Interface
	Order       optional.Interface
	SortBy      optional.String
	Drafted     optional.Bool
	Round       optional.String
	Name        optional.String
	School      optional.String
	Position    optional.Interface
	Team        optional.String
	TeamId      optional.Int32
	State       optional.String
	Country     optional.String
	PlayerId    optional.Int32
	BisPlayerId optional.Int32
}

func (a *DraftApiService) DraftProspects1(ctx context.Context, year int32, localVarOptionals *DraftApiDraftProspects1Opts) (models.ProspectListRestObject, *http.Response, error) {
	var (
		localVarHttpMethod  = strings.ToUpper("Get")
		localVarPostBody    interface{}
		localVarFileName    string
		localVarFileBytes   []byte
		localVarReturnValue models.ProspectListRestObject
	)

	// create path and map variables
	localVarPath := a.client.cfg.BasePath + "/api/v1/draft/prospects/{year}"
	localVarPath = strings.Replace(localVarPath, "{"+"year"+"}", fmt.Sprintf("%v", year), -1)

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

	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.Fields.IsSet() {
		localVarQueryParams.Add("fields", parameterToString(localVarOptionals.Fields.Value(), "multi"))
	}
	if localVarOptionals != nil && localVarOptionals.Order.IsSet() {
		localVarQueryParams.Add("order", parameterToString(localVarOptionals.Order.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.SortBy.IsSet() {
		localVarQueryParams.Add("sortBy", parameterToString(localVarOptionals.SortBy.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Drafted.IsSet() {
		localVarQueryParams.Add("drafted", parameterToString(localVarOptionals.Drafted.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Round.IsSet() {
		localVarQueryParams.Add("round", parameterToString(localVarOptionals.Round.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Name.IsSet() {
		localVarQueryParams.Add("name", parameterToString(localVarOptionals.Name.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.School.IsSet() {
		localVarQueryParams.Add("school", parameterToString(localVarOptionals.School.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Position.IsSet() {
		localVarQueryParams.Add("position", parameterToString(localVarOptionals.Position.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Team.IsSet() {
		localVarQueryParams.Add("team", parameterToString(localVarOptionals.Team.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.TeamId.IsSet() {
		localVarQueryParams.Add("teamId", parameterToString(localVarOptionals.TeamId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.State.IsSet() {
		localVarQueryParams.Add("state", parameterToString(localVarOptionals.State.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.Country.IsSet() {
		localVarQueryParams.Add("country", parameterToString(localVarOptionals.Country.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.PlayerId.IsSet() {
		localVarQueryParams.Add("playerId", parameterToString(localVarOptionals.PlayerId.Value(), ""))
	}
	if localVarOptionals != nil && localVarOptionals.BisPlayerId.IsSet() {
		localVarQueryParams.Add("bisPlayerId", parameterToString(localVarOptionals.BisPlayerId.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.ProspectListRestObject
			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
}

/*
DraftApiService Get the last drafted player and the next 5 teams up to pick
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param year Year the player was drafted. Format: 2000
 * @param optional nil or *DraftApiLatestDraftPicksOpts - Optional Parameters:
     * @param "Fields" (optional.Interface of []string) -  Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
@return models.BaseballDraftLatestRestObject
*/

type DraftApiLatestDraftPicksOpts struct {
	Fields optional.Interface
}

func (a *DraftApiService) LatestDraftPicks(ctx context.Context, year int32, localVarOptionals *DraftApiLatestDraftPicksOpts) (models.BaseballDraftLatestRestObject, *http.Response, error) {
	var (
		localVarHttpMethod  = strings.ToUpper("Get")
		localVarPostBody    interface{}
		localVarFileName    string
		localVarFileBytes   []byte
		localVarReturnValue models.BaseballDraftLatestRestObject
	)

	// create path and map variables
	localVarPath := a.client.cfg.BasePath + "/api/v1/draft/{year}/latest"
	localVarPath = strings.Replace(localVarPath, "{"+"year"+"}", fmt.Sprintf("%v", year), -1)

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

	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.BaseballDraftLatestRestObject
			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
}
