/* 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" ) // WeatherAPIService WeatherAPI service type WeatherAPIService service type ApiWeatherBasicRequest struct { ctx context.Context ApiService *WeatherAPIService venueId interface{} fields *interface{} } // 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) } /* WeatherBasic Get basic weather for a venue. Returns a json file containing basic weather for a specific venue. @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 */ func (a *WeatherAPIService) WeatherBasic(ctx context.Context, venueId interface{}) ApiWeatherBasicRequest { return ApiWeatherBasicRequest{ ApiService: a, ctx: ctx, venueId: venueId, } } // Execute executes the request func (a *WeatherAPIService) WeatherBasicExecute(r ApiWeatherBasicRequest) (*http.Response, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile ) 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) 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 } type ApiWeatherDataBasedOnPlayRequest struct { ctx context.Context ApiService *WeatherAPIService gamePk interface{} playId interface{} fields *interface{} } // 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) } /* WeatherDataBasedOnPlay Get the raw field weather data. Returns a json file containing weather for the current play. @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 */ func (a *WeatherAPIService) WeatherDataBasedOnPlay(ctx context.Context, gamePk interface{}, playId interface{}) ApiWeatherDataBasedOnPlayRequest { return ApiWeatherDataBasedOnPlayRequest{ ApiService: a, ctx: ctx, gamePk: gamePk, playId: playId, } } // Execute executes the request func (a *WeatherAPIService) WeatherDataBasedOnPlayExecute(r ApiWeatherDataBasedOnPlayRequest) (*http.Response, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile ) 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) 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 } type ApiWeatherForecastRequest struct { ctx context.Context ApiService *WeatherAPIService gamePk interface{} roofType interface{} fields *interface{} } // 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) } /* WeatherForecast Get the weather forecast for a game. Returns a json file containing the weather forecast for a specific game. @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 */ func (a *WeatherAPIService) WeatherForecast(ctx context.Context, gamePk interface{}, roofType interface{}) ApiWeatherForecastRequest { return ApiWeatherForecastRequest{ ApiService: a, ctx: ctx, gamePk: gamePk, roofType: roofType, } } // Execute executes the request func (a *WeatherAPIService) WeatherForecastExecute(r ApiWeatherForecastRequest) (*http.Response, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile ) 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) 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 } type ApiWeatherFullRequest struct { ctx context.Context ApiService *WeatherAPIService venueId interface{} fields *interface{} } // 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) } /* WeatherFull Get full weather for a venue. Returns a json file containing full weather for a specific venue. @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 */ func (a *WeatherAPIService) WeatherFull(ctx context.Context, venueId interface{}) ApiWeatherFullRequest { return ApiWeatherFullRequest{ ApiService: a, ctx: ctx, venueId: venueId, } } // Execute executes the request func (a *WeatherAPIService) WeatherFullExecute(r ApiWeatherFullRequest) (*http.Response, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile ) 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) 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 }