mlbstats/api/api_weather.go

455 lines
14 KiB
Go
Raw Normal View History

2025-04-06 04:55:01 +00:00
/*
2025-04-07 02:59:20 +00:00
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 <http://www.gnu.org/licenses/>.
*/
/*
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
// WeatherAPIService WeatherAPI service
type WeatherAPIService service
type ApiWeatherBasicRequest struct {
2025-04-07 02:14:30 +00:00
ctx context.Context
2025-04-06 23:39:04 +00:00
ApiService *WeatherAPIService
2025-04-07 02:14:30 +00:00
venueId interface{}
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 ApiWeatherBasicRequest) Fields(fields interface{}) ApiWeatherBasicRequest {
r.fields = &fields
return r
}
func (r ApiWeatherBasicRequest) Execute() (*http.Response, error) {
return r.ApiService.WeatherBasicExecute(r)
}
2025-04-06 04:55:01 +00:00
/*
2025-04-06 23:39:04 +00:00
WeatherBasic Get basic weather for a venue.
2025-04-06 04:55:01 +00:00
Returns a json file containing basic weather for a specific venue.
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 venueId Unique Venue Identifier
@return ApiWeatherBasicRequest
2025-04-06 23:39:04 +00:00
*/
func (a *WeatherAPIService) WeatherBasic(ctx context.Context, venueId interface{}) ApiWeatherBasicRequest {
return ApiWeatherBasicRequest{
ApiService: a,
2025-04-07 02:14:30 +00:00
ctx: ctx,
venueId: venueId,
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 *WeatherAPIService) WeatherBasicExecute(r ApiWeatherBasicRequest) (*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, "WeatherAPIService.WeatherBasic")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/api/v1/weather/venues/{venueId}/basic"
localVarPath = strings.Replace(localVarPath, "{"+"venueId"+"}", url.PathEscape(parameterValueToString(r.venueId, "venueId")), -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
}
type ApiWeatherDataBasedOnPlayRequest struct {
2025-04-07 02:14:30 +00:00
ctx context.Context
2025-04-06 23:39:04 +00:00
ApiService *WeatherAPIService
2025-04-07 02:14:30 +00:00
gamePk interface{}
playId interface{}
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 ApiWeatherDataBasedOnPlayRequest) Fields(fields interface{}) ApiWeatherDataBasedOnPlayRequest {
r.fields = &fields
return r
}
func (r ApiWeatherDataBasedOnPlayRequest) Execute() (*http.Response, error) {
return r.ApiService.WeatherDataBasedOnPlayExecute(r)
2025-04-06 04:55:01 +00:00
}
/*
2025-04-06 23:39:04 +00:00
WeatherDataBasedOnPlay Get the raw field weather data.
2025-04-06 04:55:01 +00:00
Returns a json file containing weather for the current play.
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 identifier for a play within a game
@return ApiWeatherDataBasedOnPlayRequest
2025-04-06 23:39:04 +00:00
*/
func (a *WeatherAPIService) WeatherDataBasedOnPlay(ctx context.Context, gamePk interface{}, playId interface{}) ApiWeatherDataBasedOnPlayRequest {
return ApiWeatherDataBasedOnPlayRequest{
ApiService: a,
2025-04-07 02:14:30 +00:00
ctx: ctx,
gamePk: gamePk,
playId: playId,
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 *WeatherAPIService) WeatherDataBasedOnPlayExecute(r ApiWeatherDataBasedOnPlayRequest) (*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, "WeatherAPIService.WeatherDataBasedOnPlay")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/api/v1/weather/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)
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
}
type ApiWeatherForecastRequest struct {
2025-04-07 02:14:30 +00:00
ctx context.Context
2025-04-06 23:39:04 +00:00
ApiService *WeatherAPIService
2025-04-07 02:14:30 +00:00
gamePk interface{}
roofType interface{}
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 ApiWeatherForecastRequest) Fields(fields interface{}) ApiWeatherForecastRequest {
r.fields = &fields
return r
}
func (r ApiWeatherForecastRequest) Execute() (*http.Response, error) {
return r.ApiService.WeatherForecastExecute(r)
2025-04-06 04:55:01 +00:00
}
/*
2025-04-06 23:39:04 +00:00
WeatherForecast Get the weather forecast for a game.
2025-04-06 04:55:01 +00:00
Returns a json file containing the weather forecast for a specific game.
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 roofType Venue roof type
@return ApiWeatherForecastRequest
2025-04-06 23:39:04 +00:00
*/
func (a *WeatherAPIService) WeatherForecast(ctx context.Context, gamePk interface{}, roofType interface{}) ApiWeatherForecastRequest {
return ApiWeatherForecastRequest{
ApiService: a,
2025-04-07 02:14:30 +00:00
ctx: ctx,
gamePk: gamePk,
roofType: roofType,
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 *WeatherAPIService) WeatherForecastExecute(r ApiWeatherForecastRequest) (*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, "WeatherAPIService.WeatherForecast")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/api/v1/weather/game/{gamePk}/forecast/{roofType}"
localVarPath = strings.Replace(localVarPath, "{"+"gamePk"+"}", url.PathEscape(parameterValueToString(r.gamePk, "gamePk")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"roofType"+"}", url.PathEscape(parameterValueToString(r.roofType, "roofType")), -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
}
type ApiWeatherFullRequest struct {
2025-04-07 02:14:30 +00:00
ctx context.Context
2025-04-06 23:39:04 +00:00
ApiService *WeatherAPIService
2025-04-07 02:14:30 +00:00
venueId interface{}
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 ApiWeatherFullRequest) Fields(fields interface{}) ApiWeatherFullRequest {
r.fields = &fields
return r
}
func (r ApiWeatherFullRequest) Execute() (*http.Response, error) {
return r.ApiService.WeatherFullExecute(r)
2025-04-06 04:55:01 +00:00
}
/*
2025-04-06 23:39:04 +00:00
WeatherFull Get full weather for a venue.
2025-04-06 04:55:01 +00:00
Returns a json file containing full weather for a specific venue.
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 venueId Unique Venue Identifier
@return ApiWeatherFullRequest
2025-04-06 23:39:04 +00:00
*/
func (a *WeatherAPIService) WeatherFull(ctx context.Context, venueId interface{}) ApiWeatherFullRequest {
return ApiWeatherFullRequest{
ApiService: a,
2025-04-07 02:14:30 +00:00
ctx: ctx,
venueId: venueId,
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 *WeatherAPIService) WeatherFullExecute(r ApiWeatherFullRequest) (*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, "WeatherAPIService.WeatherFull")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/api/v1/weather/venues/{venueId}/full"
localVarPath = strings.Replace(localVarPath, "{"+"venueId"+"}", url.PathEscape(parameterValueToString(r.venueId, "venueId")), -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
}