/* Copyright © 2025 filifa This program 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. This program 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 this program. If not, see . */ /* 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" ) // StandingsAPIService StandingsAPI service type StandingsAPIService service type ApiStandingsRequest struct { ctx context.Context ApiService *StandingsAPIService standingsType interface{} leagueId *interface{} season *interface{} standingsTypes *interface{} date *interface{} teamId *interface{} includeMLB *interface{} fields *interface{} } // Unique League Identifier func (r ApiStandingsRequest) LeagueId(leagueId interface{}) ApiStandingsRequest { r.leagueId = &leagueId return r } // Season of play func (r ApiStandingsRequest) Season(season interface{}) ApiStandingsRequest { r.season = &season return r } // Type of season. Available types in /api/v1/standingsTypes func (r ApiStandingsRequest) StandingsTypes(standingsTypes interface{}) ApiStandingsRequest { r.standingsTypes = &standingsTypes return r } // Date of Game. Format: YYYY-MM-DD func (r ApiStandingsRequest) Date(date interface{}) ApiStandingsRequest { r.date = &date return r } // Unique Team Identifier. Format: 141, 147, etc func (r ApiStandingsRequest) TeamId(teamId interface{}) ApiStandingsRequest { r.teamId = &teamId return r } // Determines whether to include major league teams when using the 'BY_ORGANIZATION' standings type func (r ApiStandingsRequest) IncludeMLB(includeMLB interface{}) ApiStandingsRequest { r.includeMLB = &includeMLB return r } // Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute func (r ApiStandingsRequest) Fields(fields interface{}) ApiStandingsRequest { r.fields = &fields return r } func (r ApiStandingsRequest) Execute() (*http.Response, error) { return r.ApiService.StandingsExecute(r) } /* Standings View standings for a league This endpoint allows you to pull standings @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param standingsType Type of season. Available types in /api/v1/standingsTypes @return ApiStandingsRequest */ func (a *StandingsAPIService) Standings(ctx context.Context, standingsType interface{}) ApiStandingsRequest { return ApiStandingsRequest{ ApiService: a, ctx: ctx, standingsType: standingsType, } } // Execute executes the request func (a *StandingsAPIService) StandingsExecute(r ApiStandingsRequest) (*http.Response, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "StandingsAPIService.Standings") if err != nil { return nil, &GenericOpenAPIError{error: err.Error()} } localVarPath := localBasePath + "/api/v1/standings/{standingsType}" localVarPath = strings.Replace(localVarPath, "{"+"standingsType"+"}", url.PathEscape(parameterValueToString(r.standingsType, "standingsType")), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if r.leagueId != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "leagueId", r.leagueId, "", "") } if r.season != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "season", r.season, "", "") } if r.standingsTypes != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "standingsTypes", r.standingsTypes, "", "") } if r.date != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "date", r.date, "", "") } if r.teamId != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "teamId", r.teamId, "", "") } if r.includeMLB != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "includeMLB", r.includeMLB, "", "") } 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 ApiStandings1Request struct { ctx context.Context ApiService *StandingsAPIService standingsType interface{} leagueId *interface{} season *interface{} standingsTypes *interface{} date *interface{} teamId *interface{} includeMLB *interface{} fields *interface{} } // Unique League Identifier func (r ApiStandings1Request) LeagueId(leagueId interface{}) ApiStandings1Request { r.leagueId = &leagueId return r } // Season of play func (r ApiStandings1Request) Season(season interface{}) ApiStandings1Request { r.season = &season return r } // Type of season. Available types in /api/v1/standingsTypes func (r ApiStandings1Request) StandingsTypes(standingsTypes interface{}) ApiStandings1Request { r.standingsTypes = &standingsTypes return r } // Date of Game. Format: YYYY-MM-DD func (r ApiStandings1Request) Date(date interface{}) ApiStandings1Request { r.date = &date return r } // Unique Team Identifier. Format: 141, 147, etc func (r ApiStandings1Request) TeamId(teamId interface{}) ApiStandings1Request { r.teamId = &teamId return r } // Determines whether to include major league teams when using the 'BY_ORGANIZATION' standings type func (r ApiStandings1Request) IncludeMLB(includeMLB interface{}) ApiStandings1Request { r.includeMLB = &includeMLB return r } // Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute func (r ApiStandings1Request) Fields(fields interface{}) ApiStandings1Request { r.fields = &fields return r } func (r ApiStandings1Request) Execute() (*http.Response, error) { return r.ApiService.Standings1Execute(r) } /* Standings1 View standings for a league This endpoint allows you to pull standings @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param standingsType Type of season. Available types in /api/v1/standingsTypes @return ApiStandings1Request */ func (a *StandingsAPIService) Standings1(ctx context.Context, standingsType interface{}) ApiStandings1Request { return ApiStandings1Request{ ApiService: a, ctx: ctx, standingsType: standingsType, } } // Execute executes the request func (a *StandingsAPIService) Standings1Execute(r ApiStandings1Request) (*http.Response, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "StandingsAPIService.Standings1") if err != nil { return nil, &GenericOpenAPIError{error: err.Error()} } localVarPath := localBasePath + "/api/v1/standings" localVarPath = strings.Replace(localVarPath, "{"+"standingsType"+"}", url.PathEscape(parameterValueToString(r.standingsType, "standingsType")), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if r.leagueId != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "leagueId", r.leagueId, "", "") } if r.season != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "season", r.season, "", "") } if r.standingsTypes != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "standingsTypes", r.standingsTypes, "", "") } if r.date != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "date", r.date, "", "") } if r.teamId != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "teamId", r.teamId, "", "") } if r.includeMLB != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "includeMLB", r.includeMLB, "", "") } 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 }