mlbstats/api/api_awards.go

373 lines
11 KiB
Go

/*
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"
)
// AwardsAPIService AwardsAPI service
type AwardsAPIService service
type ApiAwardRecipientsRequest struct {
ctx context.Context
ApiService *AwardsAPIService
awardId interface{}
season *interface{}
sportId *interface{}
leagueId *interface{}
fields *interface{}
}
// Season of play
func (r ApiAwardRecipientsRequest) Season(season interface{}) ApiAwardRecipientsRequest {
r.season = &season
return r
}
// Top level organization of a sport
func (r ApiAwardRecipientsRequest) SportId(sportId interface{}) ApiAwardRecipientsRequest {
r.sportId = &sportId
return r
}
// Comma delimited list of Unique league identifiers
func (r ApiAwardRecipientsRequest) LeagueId(leagueId interface{}) ApiAwardRecipientsRequest {
r.leagueId = &leagueId
return r
}
func (r ApiAwardRecipientsRequest) Fields(fields interface{}) ApiAwardRecipientsRequest {
r.fields = &fields
return r
}
func (r ApiAwardRecipientsRequest) Execute() (*http.Response, error) {
return r.ApiService.AwardRecipientsExecute(r)
}
/*
AwardRecipients View recipients of an award
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param awardId Unique Award Identifier. Available awards in /api/v1/awards
@return ApiAwardRecipientsRequest
*/
func (a *AwardsAPIService) AwardRecipients(ctx context.Context, awardId interface{}) ApiAwardRecipientsRequest {
return ApiAwardRecipientsRequest{
ApiService: a,
ctx: ctx,
awardId: awardId,
}
}
// Execute executes the request
func (a *AwardsAPIService) AwardRecipientsExecute(r ApiAwardRecipientsRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AwardsAPIService.AwardRecipients")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/api/v1/awards/{awardId}/recipients"
localVarPath = strings.Replace(localVarPath, "{"+"awardId"+"}", url.PathEscape(parameterValueToString(r.awardId, "awardId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.season != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "season", r.season, "", "")
}
if r.sportId != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "sportId", r.sportId, "", "")
}
if r.leagueId != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "leagueId", r.leagueId, "", "")
}
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 ApiAwardsRequest struct {
ctx context.Context
ApiService *AwardsAPIService
awardId interface{}
orgId *interface{}
fields *interface{}
}
// Comma delimited list of top level organizations of a sport
func (r ApiAwardsRequest) OrgId(orgId interface{}) ApiAwardsRequest {
r.orgId = &orgId
return r
}
// Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
func (r ApiAwardsRequest) Fields(fields interface{}) ApiAwardsRequest {
r.fields = &fields
return r
}
func (r ApiAwardsRequest) Execute() (*http.Response, error) {
return r.ApiService.AwardsExecute(r)
}
/*
Awards View awards info
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param awardId Unique Award Identifier. Available awards in /api/v1/awards
@return ApiAwardsRequest
*/
func (a *AwardsAPIService) Awards(ctx context.Context, awardId interface{}) ApiAwardsRequest {
return ApiAwardsRequest{
ApiService: a,
ctx: ctx,
awardId: awardId,
}
}
// Execute executes the request
func (a *AwardsAPIService) AwardsExecute(r ApiAwardsRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AwardsAPIService.Awards")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/api/v1/awards"
localVarPath = strings.Replace(localVarPath, "{"+"awardId"+"}", url.PathEscape(parameterValueToString(r.awardId, "awardId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.orgId != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "orgId", r.orgId, "", "")
}
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 ApiAwards1Request struct {
ctx context.Context
ApiService *AwardsAPIService
awardId interface{}
orgId *interface{}
fields *interface{}
}
// Comma delimited list of top level organizations of a sport
func (r ApiAwards1Request) OrgId(orgId interface{}) ApiAwards1Request {
r.orgId = &orgId
return r
}
// Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
func (r ApiAwards1Request) Fields(fields interface{}) ApiAwards1Request {
r.fields = &fields
return r
}
func (r ApiAwards1Request) Execute() (*http.Response, error) {
return r.ApiService.Awards1Execute(r)
}
/*
Awards1 View awards info
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param awardId Unique Award Identifier. Available awards in /api/v1/awards
@return ApiAwards1Request
*/
func (a *AwardsAPIService) Awards1(ctx context.Context, awardId interface{}) ApiAwards1Request {
return ApiAwards1Request{
ApiService: a,
ctx: ctx,
awardId: awardId,
}
}
// Execute executes the request
func (a *AwardsAPIService) Awards1Execute(r ApiAwards1Request) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AwardsAPIService.Awards1")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/api/v1/awards/{awardId}"
localVarPath = strings.Replace(localVarPath, "{"+"awardId"+"}", url.PathEscape(parameterValueToString(r.awardId, "awardId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.orgId != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "orgId", r.orgId, "", "")
}
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
}