mlbstats/api/api_predictions.go

280 lines
8.1 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"
)
2025-04-06 23:39:04 +00:00
// PredictionsAPIService PredictionsAPI service
type PredictionsAPIService service
type ApiGetPropsRequest struct {
2025-04-07 02:14:30 +00:00
ctx context.Context
ApiService *PredictionsAPIService
batterId *interface{}
pitcherId *interface{}
venueId *interface{}
batSide *interface{}
pitchHand *interface{}
batterPosition *interface{}
2025-04-06 23:39:04 +00:00
pitcherPosition *interface{}
}
// Unique Player Identifier. Format: 434538, 429665, etc
func (r ApiGetPropsRequest) BatterId(batterId interface{}) ApiGetPropsRequest {
r.batterId = &batterId
return r
}
// Unique Player Identifier. Format: 434538, 429665, etc
func (r ApiGetPropsRequest) PitcherId(pitcherId interface{}) ApiGetPropsRequest {
r.pitcherId = &pitcherId
return r
}
// Unique Venue Identifier
func (r ApiGetPropsRequest) VenueId(venueId interface{}) ApiGetPropsRequest {
r.venueId = &venueId
return r
}
// Bat side of hitter
func (r ApiGetPropsRequest) BatSide(batSide interface{}) ApiGetPropsRequest {
r.batSide = &batSide
return r
}
// Handedness of pitcher
func (r ApiGetPropsRequest) PitchHand(pitchHand interface{}) ApiGetPropsRequest {
r.pitchHand = &pitchHand
return r
}
// Position abbreviation. Format: SS, P, 1B, etc
func (r ApiGetPropsRequest) BatterPosition(batterPosition interface{}) ApiGetPropsRequest {
r.batterPosition = &batterPosition
return r
}
// Position abbreviation. Format: SS, P, 1B, etc
func (r ApiGetPropsRequest) PitcherPosition(pitcherPosition interface{}) ApiGetPropsRequest {
r.pitcherPosition = &pitcherPosition
return r
}
func (r ApiGetPropsRequest) Execute() (*http.Response, error) {
return r.ApiService.GetPropsExecute(r)
}
2025-04-06 04:55:01 +00:00
/*
2025-04-06 23:39:04 +00:00
GetProps Get play-level predictions based on input scenarios
2025-04-06 04:55:01 +00:00
This endpoint allows you to get play-level predictions based on input scenarios
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().
@return ApiGetPropsRequest
2025-04-06 23:39:04 +00:00
*/
func (a *PredictionsAPIService) GetProps(ctx context.Context) ApiGetPropsRequest {
return ApiGetPropsRequest{
ApiService: a,
2025-04-07 02:14:30 +00:00
ctx: ctx,
2025-04-06 23:39:04 +00:00
}
2025-04-06 04:55:01 +00:00
}
2025-04-06 23:39:04 +00:00
// Execute executes the request
func (a *PredictionsAPIService) GetPropsExecute(r ApiGetPropsRequest) (*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, "PredictionsAPIService.GetProps")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/api/v1/props/play/predictions"
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.batterId != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "batterId", r.batterId, "", "")
2025-04-06 04:55:01 +00:00
}
2025-04-06 23:39:04 +00:00
if r.pitcherId != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "pitcherId", r.pitcherId, "", "")
2025-04-06 04:55:01 +00:00
}
2025-04-06 23:39:04 +00:00
if r.venueId != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "venueId", r.venueId, "", "")
2025-04-06 04:55:01 +00:00
}
2025-04-06 23:39:04 +00:00
if r.batSide != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "batSide", r.batSide, "", "")
2025-04-06 04:55:01 +00:00
}
2025-04-06 23:39:04 +00:00
if r.pitchHand != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "pitchHand", r.pitchHand, "", "")
2025-04-06 04:55:01 +00:00
}
2025-04-06 23:39:04 +00:00
if r.batterPosition != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "batterPosition", r.batterPosition, "", "")
2025-04-06 04:55:01 +00:00
}
2025-04-06 23:39:04 +00:00
if r.pitcherPosition != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "pitcherPosition", r.pitcherPosition, "", "")
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
}
type ApiGetPropsAdjustRequest struct {
2025-04-07 02:14:30 +00:00
ctx context.Context
2025-04-06 23:39:04 +00:00
ApiService *PredictionsAPIService
2025-04-07 02:14:30 +00:00
gamePk *interface{}
2025-04-06 23:39:04 +00:00
}
// Unique Primary Key Representing a Game
func (r ApiGetPropsAdjustRequest) GamePk(gamePk interface{}) ApiGetPropsAdjustRequest {
r.gamePk = &gamePk
return r
}
func (r ApiGetPropsAdjustRequest) Execute() (*http.Response, error) {
return r.ApiService.GetPropsAdjustExecute(r)
2025-04-06 04:55:01 +00:00
}
/*
2025-04-06 23:39:04 +00:00
GetPropsAdjust Get play-level predictions based on input scenarios
2025-04-06 04:55:01 +00:00
This endpoint allows you to get play-level predictions based on input scenarios
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().
@return ApiGetPropsAdjustRequest
2025-04-06 04:55:01 +00:00
*/
2025-04-06 23:39:04 +00:00
func (a *PredictionsAPIService) GetPropsAdjust(ctx context.Context) ApiGetPropsAdjustRequest {
return ApiGetPropsAdjustRequest{
ApiService: a,
2025-04-07 02:14:30 +00:00
ctx: ctx,
2025-04-06 23:39:04 +00:00
}
}
// Execute executes the request
func (a *PredictionsAPIService) GetPropsAdjustExecute(r ApiGetPropsAdjustRequest) (*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, "PredictionsAPIService.GetPropsAdjust")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/api/v1/props/play/predictions/adjust"
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.gamePk == nil {
return nil, reportError("gamePk is required and must be specified")
}
2025-04-06 04:55:01 +00:00
2025-04-06 23:39:04 +00:00
parameterAddToHeaderOrQuery(localVarQueryParams, "gamePk", r.gamePk, "", "")
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
}