mlbstats/api/api_biomechanics.go

134 lines
4.2 KiB
Go
Raw Normal View History

2025-04-06 04:55:01 +00:00
/*
2025-04-06 23:39:04 +00:00
Stats API Documentation
2025-04-06 04:55:01 +00:00
2025-04-06 23:39:04 +00:00
Official API for Major League Baseball.
2025-04-06 04:55:01 +00:00
2025-04-06 23:39:04 +00:00
API version: 2.0.0
2025-04-06 04:55:01 +00:00
*/
2025-04-06 23:39:04 +00:00
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
2025-04-06 04:55:01 +00:00
package api
import (
2025-04-06 23:39:04 +00:00
"bytes"
2025-04-06 04:55:01 +00:00
"context"
2025-04-06 23:39:04 +00:00
"io"
2025-04-06 04:55:01 +00:00
"net/http"
"net/url"
"strings"
)
2025-04-06 23:39:04 +00:00
// BiomechanicsAPIService BiomechanicsAPI service
type BiomechanicsAPIService service
type ApiBiomechanicalRequest struct {
2025-04-07 02:14:30 +00:00
ctx context.Context
2025-04-06 23:39:04 +00:00
ApiService *BiomechanicsAPIService
2025-04-07 02:14:30 +00:00
gamePk interface{}
playId interface{}
2025-04-06 23:39:04 +00:00
positionId interface{}
2025-04-07 02:14:30 +00:00
fields *interface{}
2025-04-06 23:39:04 +00:00
}
// Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
func (r ApiBiomechanicalRequest) Fields(fields interface{}) ApiBiomechanicalRequest {
r.fields = &fields
return r
}
func (r ApiBiomechanicalRequest) Execute() (*http.Response, error) {
return r.ApiService.BiomechanicalExecute(r)
}
2025-04-06 04:55:01 +00:00
/*
2025-04-06 23:39:04 +00:00
Biomechanical View Biomechanical data by playId and gameId filtered by player positionId
2025-04-06 04:55:01 +00:00
This endpoint allows you to pull biomechanical tracking data by gameId and playId filtered by player positionId
2025-04-07 02:14:30 +00:00
@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
@param positionId Position number. Format: 1, 2, 3, etc
@return ApiBiomechanicalRequest
2025-04-06 23:39:04 +00:00
*/
func (a *BiomechanicsAPIService) Biomechanical(ctx context.Context, gamePk interface{}, playId interface{}, positionId interface{}) ApiBiomechanicalRequest {
return ApiBiomechanicalRequest{
ApiService: a,
2025-04-07 02:14:30 +00:00
ctx: ctx,
gamePk: gamePk,
playId: playId,
2025-04-06 23:39:04 +00:00
positionId: positionId,
}
2025-04-06 04:55:01 +00:00
}
2025-04-06 23:39:04 +00:00
// Execute executes the request
func (a *BiomechanicsAPIService) BiomechanicalExecute(r ApiBiomechanicalRequest) (*http.Response, error) {
2025-04-06 04:55:01 +00:00
var (
2025-04-07 02:14:30 +00:00
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
2025-04-06 04:55:01 +00:00
)
2025-04-06 23:39:04 +00:00
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BiomechanicsAPIService.Biomechanical")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/api/v1/game/{gamePk}/{playId}/analytics/biomechanics/{positionId}"
localVarPath = strings.Replace(localVarPath, "{"+"gamePk"+"}", url.PathEscape(parameterValueToString(r.gamePk, "gamePk")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"playId"+"}", url.PathEscape(parameterValueToString(r.playId, "playId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"positionId"+"}", url.PathEscape(parameterValueToString(r.positionId, "positionId")), -1)
2025-04-06 04:55:01 +00:00
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
2025-04-06 23:39:04 +00:00
if r.fields != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "fields", r.fields, "", "")
2025-04-06 04:55:01 +00:00
}
// to determine the Content-Type header
2025-04-06 23:39:04 +00:00
localVarHTTPContentTypes := []string{}
2025-04-06 04:55:01 +00:00
// set Content-Type header
2025-04-06 23:39:04 +00:00
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
2025-04-06 04:55:01 +00:00
}
// to determine the Accept header
2025-04-06 23:39:04 +00:00
localVarHTTPHeaderAccepts := []string{}
2025-04-06 04:55:01 +00:00
// set Accept header
2025-04-06 23:39:04 +00:00
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
2025-04-06 04:55:01 +00:00
}
2025-04-06 23:39:04 +00:00
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
2025-04-06 04:55:01 +00:00
if err != nil {
2025-04-06 23:39:04 +00:00
return nil, err
2025-04-06 04:55:01 +00:00
}
2025-04-06 23:39:04 +00:00
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
2025-04-06 04:55:01 +00:00
}
2025-04-06 23:39:04 +00:00
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
2025-04-06 04:55:01 +00:00
if err != nil {
2025-04-06 23:39:04 +00:00
return localVarHTTPResponse, err
2025-04-06 04:55:01 +00:00
}
2025-04-06 23:39:04 +00:00
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
2025-04-06 04:55:01 +00:00
body: localVarBody,
2025-04-06 23:39:04 +00:00
error: localVarHTTPResponse.Status,
2025-04-06 04:55:01 +00:00
}
2025-04-06 23:39:04 +00:00
return localVarHTTPResponse, newErr
2025-04-06 04:55:01 +00:00
}
2025-04-06 23:39:04 +00:00
return localVarHTTPResponse, nil
2025-04-06 04:55:01 +00:00
}