mlbstats/api/api_game_pace.go

280 lines
8.0 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"
)
// GamePaceAPIService GamePaceAPI service
type GamePaceAPIService service
type ApiGamePaceRequest struct {
ctx context.Context
ApiService *GamePaceAPIService
season *interface{}
teamId *interface{}
teamIds *interface{}
leagueId *interface{}
leagueIds *interface{}
leagueListId *interface{}
sportId *interface{}
sportIds *interface{}
gameType *interface{}
startDate *interface{}
endDate *interface{}
venueIds *interface{}
excludeVenueIds *interface{}
excludeGamePks *interface{}
orgType *interface{}
includeChildren *interface{}
fields *interface{}
}
// Season of play
func (r ApiGamePaceRequest) Season(season interface{}) ApiGamePaceRequest {
r.season = &season
return r
}
// Unique Team Identifier. Format: 141, 147, etc
func (r ApiGamePaceRequest) TeamId(teamId interface{}) ApiGamePaceRequest {
r.teamId = &teamId
return r
}
// Comma delimited list of Unique Team identifiers
func (r ApiGamePaceRequest) TeamIds(teamIds interface{}) ApiGamePaceRequest {
r.teamIds = &teamIds
return r
}
// Unique League Identifier
func (r ApiGamePaceRequest) LeagueId(leagueId interface{}) ApiGamePaceRequest {
r.leagueId = &leagueId
return r
}
// Comma delimited list of Unique league identifiers
func (r ApiGamePaceRequest) LeagueIds(leagueIds interface{}) ApiGamePaceRequest {
r.leagueIds = &leagueIds
return r
}
// Unique League List Identifier
func (r ApiGamePaceRequest) LeagueListId(leagueListId interface{}) ApiGamePaceRequest {
r.leagueListId = &leagueListId
return r
}
// Top level organization of a sport
func (r ApiGamePaceRequest) SportId(sportId interface{}) ApiGamePaceRequest {
r.sportId = &sportId
return r
}
// Comma delimited list of top level organizations of a sport
func (r ApiGamePaceRequest) SportIds(sportIds interface{}) ApiGamePaceRequest {
r.sportIds = &sportIds
return r
}
// Type of Game. Available types in /api/v1/gameTypes
func (r ApiGamePaceRequest) GameType(gameType interface{}) ApiGamePaceRequest {
r.gameType = &gameType
return r
}
// Start date for range of data (must be used with end date). Format: MM/DD/YYYY
func (r ApiGamePaceRequest) StartDate(startDate interface{}) ApiGamePaceRequest {
r.startDate = &startDate
return r
}
// End date for range of data (must be used with start date). Format: MM/DD/YYYY
func (r ApiGamePaceRequest) EndDate(endDate interface{}) ApiGamePaceRequest {
r.endDate = &endDate
return r
}
// Comma delimited list of Unique venue identifiers
func (r ApiGamePaceRequest) VenueIds(venueIds interface{}) ApiGamePaceRequest {
r.venueIds = &venueIds
return r
}
// Comma delimited list of Unique venue identifiers
func (r ApiGamePaceRequest) ExcludeVenueIds(excludeVenueIds interface{}) ApiGamePaceRequest {
r.excludeVenueIds = &excludeVenueIds
return r
}
// Comma delimited list of unique primary keys
func (r ApiGamePaceRequest) ExcludeGamePks(excludeGamePks interface{}) ApiGamePaceRequest {
r.excludeGamePks = &excludeGamePks
return r
}
// Organization level. Format: T(Team), L(League), S(Sport)
func (r ApiGamePaceRequest) OrgType(orgType interface{}) ApiGamePaceRequest {
r.orgType = &orgType
return r
}
// Determines weather to include results from an organization's children (ex. a sport would also include results for the teams and leagues)
func (r ApiGamePaceRequest) IncludeChildren(includeChildren interface{}) ApiGamePaceRequest {
r.includeChildren = &includeChildren
return r
}
// Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
func (r ApiGamePaceRequest) Fields(fields interface{}) ApiGamePaceRequest {
r.fields = &fields
return r
}
func (r ApiGamePaceRequest) Execute() (*http.Response, error) {
return r.ApiService.GamePaceExecute(r)
}
/*
GamePace View time of game info
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return ApiGamePaceRequest
*/
func (a *GamePaceAPIService) GamePace(ctx context.Context) ApiGamePaceRequest {
return ApiGamePaceRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
func (a *GamePaceAPIService) GamePaceExecute(r ApiGamePaceRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "GamePaceAPIService.GamePace")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/api/v1/gamePace"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.season != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "season", r.season, "", "")
}
if r.teamId != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "teamId", r.teamId, "", "")
}
if r.teamIds != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "teamIds", r.teamIds, "", "")
}
if r.leagueId != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "leagueId", r.leagueId, "", "")
}
if r.leagueIds != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "leagueIds", r.leagueIds, "", "")
}
if r.leagueListId != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "leagueListId", r.leagueListId, "", "")
}
if r.sportId != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "sportId", r.sportId, "", "")
}
if r.sportIds != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "sportIds", r.sportIds, "", "")
}
if r.gameType != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "gameType", r.gameType, "", "")
}
if r.startDate != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "startDate", r.startDate, "", "")
}
if r.endDate != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "endDate", r.endDate, "", "")
}
if r.venueIds != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "venueIds", r.venueIds, "", "")
}
if r.excludeVenueIds != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "excludeVenueIds", r.excludeVenueIds, "", "")
}
if r.excludeGamePks != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "excludeGamePks", r.excludeGamePks, "", "")
}
if r.orgType != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "orgType", r.orgType, "", "")
}
if r.includeChildren != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "includeChildren", r.includeChildren, "", "")
}
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
}