/* 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" ) // BatTrackingAPIService BatTrackingAPI service type BatTrackingAPIService service type ApiBatTrackingRequest struct { ctx context.Context ApiService *BatTrackingAPIService gamePk interface{} playId interface{} fields *interface{} } // Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute func (r ApiBatTrackingRequest) Fields(fields interface{}) ApiBatTrackingRequest { r.fields = &fields return r } func (r ApiBatTrackingRequest) Execute() (*http.Response, error) { return r.ApiService.BatTrackingExecute(r) } /* BatTracking View Bat Tracking Data by playId and gameId This endpoint allows you to pull bat tracking data by gameId and playId @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param gamePk Unique Primary Key Representing a Game @param playId Unique play identifier @return ApiBatTrackingRequest */ func (a *BatTrackingAPIService) BatTracking(ctx context.Context, gamePk interface{}, playId interface{}) ApiBatTrackingRequest { return ApiBatTrackingRequest{ ApiService: a, ctx: ctx, gamePk: gamePk, playId: playId, } } // Execute executes the request func (a *BatTrackingAPIService) BatTrackingExecute(r ApiBatTrackingRequest) (*http.Response, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BatTrackingAPIService.BatTracking") if err != nil { return nil, &GenericOpenAPIError{error: err.Error()} } localVarPath := localBasePath + "/api/v1/batTracking/game/{gamePk}/{playId}" localVarPath = strings.Replace(localVarPath, "{"+"gamePk"+"}", url.PathEscape(parameterValueToString(r.gamePk, "gamePk")), -1) localVarPath = strings.Replace(localVarPath, "{"+"playId"+"}", url.PathEscape(parameterValueToString(r.playId, "playId")), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} 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 }