543 lines
16 KiB
Go
543 lines
16 KiB
Go
/*
|
|
Stats API Documentation
|
|
|
|
Official API for Major League Baseball.
|
|
|
|
API version: 2.0.0
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
|
|
package api
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"io"
|
|
"net/http"
|
|
"net/url"
|
|
"strings"
|
|
)
|
|
|
|
|
|
// SportsAPIService SportsAPI service
|
|
type SportsAPIService service
|
|
|
|
type ApiAllSportBallotRequest struct {
|
|
ctx context.Context
|
|
ApiService *SportsAPIService
|
|
sportId interface{}
|
|
season *interface{}
|
|
fields *interface{}
|
|
}
|
|
|
|
// season
|
|
func (r ApiAllSportBallotRequest) Season(season interface{}) ApiAllSportBallotRequest {
|
|
r.season = &season
|
|
return r
|
|
}
|
|
|
|
func (r ApiAllSportBallotRequest) Fields(fields interface{}) ApiAllSportBallotRequest {
|
|
r.fields = &fields
|
|
return r
|
|
}
|
|
|
|
func (r ApiAllSportBallotRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.AllSportBallotExecute(r)
|
|
}
|
|
|
|
/*
|
|
AllSportBallot Get ALL MLB ballot for sport
|
|
|
|
This endpoint allows you to get all players for MLB ballot
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param sportId Top level organization of a sport
|
|
@return ApiAllSportBallotRequest
|
|
*/
|
|
func (a *SportsAPIService) AllSportBallot(ctx context.Context, sportId interface{}) ApiAllSportBallotRequest {
|
|
return ApiAllSportBallotRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
sportId: sportId,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *SportsAPIService) AllSportBallotExecute(r ApiAllSportBallotRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "SportsAPIService.AllSportBallot")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/api/v1/sports/{sportId}/allSportBallot"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"sportId"+"}", url.PathEscape(parameterValueToString(r.sportId, "sportId")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.season == nil {
|
|
return nil, reportError("season is required and must be specified")
|
|
}
|
|
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "season", r.season, "", "")
|
|
if r.fields != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "fields", r.fields, "", "")
|
|
}
|
|
// 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
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarHTTPResponse, nil
|
|
}
|
|
|
|
type ApiSportPlayersRequest struct {
|
|
ctx context.Context
|
|
ApiService *SportsAPIService
|
|
sportId interface{}
|
|
season *interface{}
|
|
gameType *interface{}
|
|
hasStats *interface{}
|
|
accent *interface{}
|
|
fields *interface{}
|
|
}
|
|
|
|
// Season of play
|
|
func (r ApiSportPlayersRequest) Season(season interface{}) ApiSportPlayersRequest {
|
|
r.season = &season
|
|
return r
|
|
}
|
|
|
|
// Type of Game. Available types in /api/v1/gameTypes
|
|
func (r ApiSportPlayersRequest) GameType(gameType interface{}) ApiSportPlayersRequest {
|
|
r.gameType = &gameType
|
|
return r
|
|
}
|
|
|
|
// Returns sports that have individual player stats
|
|
func (r ApiSportPlayersRequest) HasStats(hasStats interface{}) ApiSportPlayersRequest {
|
|
r.hasStats = &hasStats
|
|
return r
|
|
}
|
|
|
|
// Boolean value to specify wanting a person's name with accents or without
|
|
func (r ApiSportPlayersRequest) Accent(accent interface{}) ApiSportPlayersRequest {
|
|
r.accent = &accent
|
|
return r
|
|
}
|
|
|
|
// Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
|
|
func (r ApiSportPlayersRequest) Fields(fields interface{}) ApiSportPlayersRequest {
|
|
r.fields = &fields
|
|
return r
|
|
}
|
|
|
|
func (r ApiSportPlayersRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.SportPlayersExecute(r)
|
|
}
|
|
|
|
/*
|
|
SportPlayers Get all players for a sport level
|
|
|
|
This endpoint allows you to pull all players for a given sport
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param sportId Top level organization of a sport
|
|
@return ApiSportPlayersRequest
|
|
*/
|
|
func (a *SportsAPIService) SportPlayers(ctx context.Context, sportId interface{}) ApiSportPlayersRequest {
|
|
return ApiSportPlayersRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
sportId: sportId,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *SportsAPIService) SportPlayersExecute(r ApiSportPlayersRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "SportsAPIService.SportPlayers")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/api/v1/sports/{sportId}/players"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"sportId"+"}", url.PathEscape(parameterValueToString(r.sportId, "sportId")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.season != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "season", r.season, "", "")
|
|
}
|
|
if r.gameType != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "gameType", r.gameType, "", "")
|
|
}
|
|
if r.hasStats != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "hasStats", r.hasStats, "", "")
|
|
}
|
|
if r.accent != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "accent", r.accent, "", "")
|
|
}
|
|
if r.fields != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "fields", r.fields, "", "")
|
|
}
|
|
// 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
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarHTTPResponse, nil
|
|
}
|
|
|
|
type ApiSportsRequest struct {
|
|
ctx context.Context
|
|
ApiService *SportsAPIService
|
|
sportId interface{}
|
|
season *interface{}
|
|
fields *interface{}
|
|
hasStats *interface{}
|
|
activeStatus *interface{}
|
|
}
|
|
|
|
// Season of play
|
|
func (r ApiSportsRequest) Season(season interface{}) ApiSportsRequest {
|
|
r.season = &season
|
|
return r
|
|
}
|
|
|
|
// Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
|
|
func (r ApiSportsRequest) Fields(fields interface{}) ApiSportsRequest {
|
|
r.fields = &fields
|
|
return r
|
|
}
|
|
|
|
// Returns sports that have individual player stats
|
|
func (r ApiSportsRequest) HasStats(hasStats interface{}) ApiSportsRequest {
|
|
r.hasStats = &hasStats
|
|
return r
|
|
}
|
|
|
|
// Flag for fetching sports that are currently active (Y), inactive (N), pending (P), or all teams (B)
|
|
func (r ApiSportsRequest) ActiveStatus(activeStatus interface{}) ApiSportsRequest {
|
|
r.activeStatus = &activeStatus
|
|
return r
|
|
}
|
|
|
|
func (r ApiSportsRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.SportsExecute(r)
|
|
}
|
|
|
|
/*
|
|
Sports Get sports information
|
|
|
|
This endpoint allows you to pull sports
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param sportId Top level organization of a sport
|
|
@return ApiSportsRequest
|
|
*/
|
|
func (a *SportsAPIService) Sports(ctx context.Context, sportId interface{}) ApiSportsRequest {
|
|
return ApiSportsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
sportId: sportId,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *SportsAPIService) SportsExecute(r ApiSportsRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "SportsAPIService.Sports")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/api/v1/sports"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"sportId"+"}", url.PathEscape(parameterValueToString(r.sportId, "sportId")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.season != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "season", r.season, "", "")
|
|
}
|
|
if r.fields != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "fields", r.fields, "", "")
|
|
}
|
|
if r.hasStats != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "hasStats", r.hasStats, "", "")
|
|
}
|
|
if r.activeStatus != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "activeStatus", r.activeStatus, "", "")
|
|
}
|
|
// 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
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarHTTPResponse, nil
|
|
}
|
|
|
|
type ApiSports1Request struct {
|
|
ctx context.Context
|
|
ApiService *SportsAPIService
|
|
sportId interface{}
|
|
season *interface{}
|
|
fields *interface{}
|
|
hasStats *interface{}
|
|
activeStatus *interface{}
|
|
}
|
|
|
|
// Season of play
|
|
func (r ApiSports1Request) Season(season interface{}) ApiSports1Request {
|
|
r.season = &season
|
|
return r
|
|
}
|
|
|
|
// Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
|
|
func (r ApiSports1Request) Fields(fields interface{}) ApiSports1Request {
|
|
r.fields = &fields
|
|
return r
|
|
}
|
|
|
|
// Returns sports that have individual player stats
|
|
func (r ApiSports1Request) HasStats(hasStats interface{}) ApiSports1Request {
|
|
r.hasStats = &hasStats
|
|
return r
|
|
}
|
|
|
|
// Flag for fetching sports that are currently active (Y), inactive (N), pending (P), or all teams (B)
|
|
func (r ApiSports1Request) ActiveStatus(activeStatus interface{}) ApiSports1Request {
|
|
r.activeStatus = &activeStatus
|
|
return r
|
|
}
|
|
|
|
func (r ApiSports1Request) Execute() (*http.Response, error) {
|
|
return r.ApiService.Sports1Execute(r)
|
|
}
|
|
|
|
/*
|
|
Sports1 Get sports information
|
|
|
|
This endpoint allows you to pull sports
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param sportId Top level organization of a sport
|
|
@return ApiSports1Request
|
|
*/
|
|
func (a *SportsAPIService) Sports1(ctx context.Context, sportId interface{}) ApiSports1Request {
|
|
return ApiSports1Request{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
sportId: sportId,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *SportsAPIService) Sports1Execute(r ApiSports1Request) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "SportsAPIService.Sports1")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/api/v1/sports/{sportId}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"sportId"+"}", url.PathEscape(parameterValueToString(r.sportId, "sportId")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.season != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "season", r.season, "", "")
|
|
}
|
|
if r.fields != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "fields", r.fields, "", "")
|
|
}
|
|
if r.hasStats != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "hasStats", r.hasStats, "", "")
|
|
}
|
|
if r.activeStatus != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "activeStatus", r.activeStatus, "", "")
|
|
}
|
|
// 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
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarHTTPResponse, nil
|
|
}
|