1683 lines
51 KiB
Go
1683 lines
51 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"
|
|
)
|
|
|
|
// PersonAPIService PersonAPI service
|
|
type PersonAPIService service
|
|
|
|
type ApiAwardRequest struct {
|
|
ctx context.Context
|
|
ApiService *PersonAPIService
|
|
personId interface{}
|
|
fields *interface{}
|
|
}
|
|
|
|
// Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
|
|
func (r ApiAwardRequest) Fields(fields interface{}) ApiAwardRequest {
|
|
r.fields = &fields
|
|
return r
|
|
}
|
|
|
|
func (r ApiAwardRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.AwardExecute(r)
|
|
}
|
|
|
|
/*
|
|
Award View a player's awards
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param personId Unique Player Identifier. Format: 434538, 429665, etc
|
|
@return ApiAwardRequest
|
|
*/
|
|
func (a *PersonAPIService) Award(ctx context.Context, personId interface{}) ApiAwardRequest {
|
|
return ApiAwardRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
personId: personId,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *PersonAPIService) AwardExecute(r ApiAwardRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PersonAPIService.Award")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/api/v1/people/{personId}/awards"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"personId"+"}", url.PathEscape(parameterValueToString(r.personId, "personId")), -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 ApiCurrentGameStatsRequest struct {
|
|
ctx context.Context
|
|
ApiService *PersonAPIService
|
|
updatedSince *interface{}
|
|
limit *interface{}
|
|
offset *interface{}
|
|
accent *interface{}
|
|
fields *interface{}
|
|
}
|
|
|
|
// Format: YYYY-MM-DDTHH:MM:SSZ
|
|
func (r ApiCurrentGameStatsRequest) UpdatedSince(updatedSince interface{}) ApiCurrentGameStatsRequest {
|
|
r.updatedSince = &updatedSince
|
|
return r
|
|
}
|
|
|
|
// Number of results to return
|
|
func (r ApiCurrentGameStatsRequest) Limit(limit interface{}) ApiCurrentGameStatsRequest {
|
|
r.limit = &limit
|
|
return r
|
|
}
|
|
|
|
// The pointer to start for a return set; used for pagination
|
|
func (r ApiCurrentGameStatsRequest) Offset(offset interface{}) ApiCurrentGameStatsRequest {
|
|
r.offset = &offset
|
|
return r
|
|
}
|
|
|
|
// Boolean value to specify wanting a person's name with accents or without
|
|
func (r ApiCurrentGameStatsRequest) Accent(accent interface{}) ApiCurrentGameStatsRequest {
|
|
r.accent = &accent
|
|
return r
|
|
}
|
|
|
|
// Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
|
|
func (r ApiCurrentGameStatsRequest) Fields(fields interface{}) ApiCurrentGameStatsRequest {
|
|
r.fields = &fields
|
|
return r
|
|
}
|
|
|
|
func (r ApiCurrentGameStatsRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.CurrentGameStatsExecute(r)
|
|
}
|
|
|
|
/*
|
|
CurrentGameStats View a player's change log
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return ApiCurrentGameStatsRequest
|
|
*/
|
|
func (a *PersonAPIService) CurrentGameStats(ctx context.Context) ApiCurrentGameStatsRequest {
|
|
return ApiCurrentGameStatsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *PersonAPIService) CurrentGameStatsExecute(r ApiCurrentGameStatsRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PersonAPIService.CurrentGameStats")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/api/v1/people/changes"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.updatedSince == nil {
|
|
return nil, reportError("updatedSince is required and must be specified")
|
|
}
|
|
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "updatedSince", r.updatedSince, "", "")
|
|
if r.limit != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "", "")
|
|
}
|
|
if r.offset != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "offset", r.offset, "", "")
|
|
}
|
|
if r.accent != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "accent", r.accent, "", "")
|
|
}
|
|
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 ApiFreeAgentsRequest struct {
|
|
ctx context.Context
|
|
ApiService *PersonAPIService
|
|
season *interface{}
|
|
order *interface{}
|
|
accent *interface{}
|
|
fields *interface{}
|
|
}
|
|
|
|
// Season of play
|
|
func (r ApiFreeAgentsRequest) Season(season interface{}) ApiFreeAgentsRequest {
|
|
r.season = &season
|
|
return r
|
|
}
|
|
|
|
// The order of sorting, ascending or descending
|
|
func (r ApiFreeAgentsRequest) Order(order interface{}) ApiFreeAgentsRequest {
|
|
r.order = &order
|
|
return r
|
|
}
|
|
|
|
// Boolean value to specify wanting a person's name with accents or without
|
|
func (r ApiFreeAgentsRequest) Accent(accent interface{}) ApiFreeAgentsRequest {
|
|
r.accent = &accent
|
|
return r
|
|
}
|
|
|
|
func (r ApiFreeAgentsRequest) Fields(fields interface{}) ApiFreeAgentsRequest {
|
|
r.fields = &fields
|
|
return r
|
|
}
|
|
|
|
func (r ApiFreeAgentsRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.FreeAgentsExecute(r)
|
|
}
|
|
|
|
/*
|
|
FreeAgents Get free agents
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return ApiFreeAgentsRequest
|
|
*/
|
|
func (a *PersonAPIService) FreeAgents(ctx context.Context) ApiFreeAgentsRequest {
|
|
return ApiFreeAgentsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *PersonAPIService) FreeAgentsExecute(r ApiFreeAgentsRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PersonAPIService.FreeAgents")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/api/v1/people/freeAgents"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.season == nil {
|
|
return nil, reportError("season is required and must be specified")
|
|
}
|
|
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "season", r.season, "", "")
|
|
if r.order != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "order", r.order, "", "")
|
|
}
|
|
if r.accent != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "accent", r.accent, "", "")
|
|
}
|
|
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 ApiPersonRequest struct {
|
|
ctx context.Context
|
|
ApiService *PersonAPIService
|
|
personId interface{}
|
|
personIds *interface{}
|
|
accent *interface{}
|
|
season *interface{}
|
|
group *interface{}
|
|
fields *interface{}
|
|
}
|
|
|
|
// Comma delimited list of person ID. Format: 1234, 2345
|
|
func (r ApiPersonRequest) PersonIds(personIds interface{}) ApiPersonRequest {
|
|
r.personIds = &personIds
|
|
return r
|
|
}
|
|
|
|
// Boolean value to specify wanting a person's name with accents or without
|
|
func (r ApiPersonRequest) Accent(accent interface{}) ApiPersonRequest {
|
|
r.accent = &accent
|
|
return r
|
|
}
|
|
|
|
// Season of play
|
|
func (r ApiPersonRequest) Season(season interface{}) ApiPersonRequest {
|
|
r.season = &season
|
|
return r
|
|
}
|
|
|
|
// Category of statistic to return. Available types in /api/v1/statGroups
|
|
func (r ApiPersonRequest) Group(group interface{}) ApiPersonRequest {
|
|
r.group = &group
|
|
return r
|
|
}
|
|
|
|
// Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
|
|
func (r ApiPersonRequest) Fields(fields interface{}) ApiPersonRequest {
|
|
r.fields = &fields
|
|
return r
|
|
}
|
|
|
|
func (r ApiPersonRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.PersonExecute(r)
|
|
}
|
|
|
|
/*
|
|
Person View a player
|
|
|
|
This endpoint allows you to pull the information of players
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param personId Unique Player Identifier. Format: 434538, 429665, etc
|
|
@return ApiPersonRequest
|
|
*/
|
|
func (a *PersonAPIService) Person(ctx context.Context, personId interface{}) ApiPersonRequest {
|
|
return ApiPersonRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
personId: personId,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *PersonAPIService) PersonExecute(r ApiPersonRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PersonAPIService.Person")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/api/v1/people/{personId}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"personId"+"}", url.PathEscape(parameterValueToString(r.personId, "personId")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.personIds != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "personIds", r.personIds, "", "")
|
|
}
|
|
if r.accent != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "accent", r.accent, "", "")
|
|
}
|
|
if r.season != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "season", r.season, "", "")
|
|
}
|
|
if r.group != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "group", r.group, "", "")
|
|
}
|
|
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 ApiPerson1Request struct {
|
|
ctx context.Context
|
|
ApiService *PersonAPIService
|
|
personId interface{}
|
|
personIds *interface{}
|
|
accent *interface{}
|
|
season *interface{}
|
|
group *interface{}
|
|
fields *interface{}
|
|
}
|
|
|
|
// Comma delimited list of person ID. Format: 1234, 2345
|
|
func (r ApiPerson1Request) PersonIds(personIds interface{}) ApiPerson1Request {
|
|
r.personIds = &personIds
|
|
return r
|
|
}
|
|
|
|
// Boolean value to specify wanting a person's name with accents or without
|
|
func (r ApiPerson1Request) Accent(accent interface{}) ApiPerson1Request {
|
|
r.accent = &accent
|
|
return r
|
|
}
|
|
|
|
// Season of play
|
|
func (r ApiPerson1Request) Season(season interface{}) ApiPerson1Request {
|
|
r.season = &season
|
|
return r
|
|
}
|
|
|
|
// Category of statistic to return. Available types in /api/v1/statGroups
|
|
func (r ApiPerson1Request) Group(group interface{}) ApiPerson1Request {
|
|
r.group = &group
|
|
return r
|
|
}
|
|
|
|
// Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
|
|
func (r ApiPerson1Request) Fields(fields interface{}) ApiPerson1Request {
|
|
r.fields = &fields
|
|
return r
|
|
}
|
|
|
|
func (r ApiPerson1Request) Execute() (*http.Response, error) {
|
|
return r.ApiService.Person1Execute(r)
|
|
}
|
|
|
|
/*
|
|
Person1 View a player
|
|
|
|
This endpoint allows you to pull the information of players
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param personId Unique Player Identifier. Format: 434538, 429665, etc
|
|
@return ApiPerson1Request
|
|
*/
|
|
func (a *PersonAPIService) Person1(ctx context.Context, personId interface{}) ApiPerson1Request {
|
|
return ApiPerson1Request{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
personId: personId,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *PersonAPIService) Person1Execute(r ApiPerson1Request) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PersonAPIService.Person1")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/api/v1/people"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"personId"+"}", url.PathEscape(parameterValueToString(r.personId, "personId")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.personIds != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "personIds", r.personIds, "", "")
|
|
}
|
|
if r.accent != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "accent", r.accent, "", "")
|
|
}
|
|
if r.season != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "season", r.season, "", "")
|
|
}
|
|
if r.group != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "group", r.group, "", "")
|
|
}
|
|
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 ApiPlayerGameStatsRequest struct {
|
|
ctx context.Context
|
|
ApiService *PersonAPIService
|
|
personId interface{}
|
|
gamePk interface{}
|
|
group *interface{}
|
|
fields *interface{}
|
|
}
|
|
|
|
// Category of statistic to return. Available types in /api/v1/statGroups
|
|
func (r ApiPlayerGameStatsRequest) Group(group interface{}) ApiPlayerGameStatsRequest {
|
|
r.group = &group
|
|
return r
|
|
}
|
|
|
|
// Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
|
|
func (r ApiPlayerGameStatsRequest) Fields(fields interface{}) ApiPlayerGameStatsRequest {
|
|
r.fields = &fields
|
|
return r
|
|
}
|
|
|
|
func (r ApiPlayerGameStatsRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.PlayerGameStatsExecute(r)
|
|
}
|
|
|
|
/*
|
|
PlayerGameStats View a player's game stats
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param personId Unique Player Identifier. Format: 434538, 429665, etc
|
|
@param gamePk Unique Primary Key Representing a Game
|
|
@return ApiPlayerGameStatsRequest
|
|
*/
|
|
func (a *PersonAPIService) PlayerGameStats(ctx context.Context, personId interface{}, gamePk interface{}) ApiPlayerGameStatsRequest {
|
|
return ApiPlayerGameStatsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
personId: personId,
|
|
gamePk: gamePk,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *PersonAPIService) PlayerGameStatsExecute(r ApiPlayerGameStatsRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PersonAPIService.PlayerGameStats")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/api/v1/people/{personId}/stats/game/{gamePk}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"personId"+"}", url.PathEscape(parameterValueToString(r.personId, "personId")), -1)
|
|
localVarPath = strings.Replace(localVarPath, "{"+"gamePk"+"}", url.PathEscape(parameterValueToString(r.gamePk, "gamePk")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.group != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "group", r.group, "", "")
|
|
}
|
|
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 ApiSearchRequest struct {
|
|
ctx context.Context
|
|
ApiService *PersonAPIService
|
|
names *interface{}
|
|
personIds *interface{}
|
|
sportIds *interface{}
|
|
leagueIds *interface{}
|
|
teamIds *interface{}
|
|
leagueListId *interface{}
|
|
active *interface{}
|
|
verified *interface{}
|
|
rookie *interface{}
|
|
seasons *interface{}
|
|
fields *interface{}
|
|
accent *interface{}
|
|
limit *interface{}
|
|
}
|
|
|
|
// Name a player uses
|
|
func (r ApiSearchRequest) Names(names interface{}) ApiSearchRequest {
|
|
r.names = &names
|
|
return r
|
|
}
|
|
|
|
// Comma delimited list of person ID. Format: 1234, 2345
|
|
func (r ApiSearchRequest) PersonIds(personIds interface{}) ApiSearchRequest {
|
|
r.personIds = &personIds
|
|
return r
|
|
}
|
|
|
|
// Comma delimited list of top level organizations of a sport
|
|
func (r ApiSearchRequest) SportIds(sportIds interface{}) ApiSearchRequest {
|
|
r.sportIds = &sportIds
|
|
return r
|
|
}
|
|
|
|
// Comma delimited list of Unique league identifiers
|
|
func (r ApiSearchRequest) LeagueIds(leagueIds interface{}) ApiSearchRequest {
|
|
r.leagueIds = &leagueIds
|
|
return r
|
|
}
|
|
|
|
// Comma delimited list of Unique Team identifiers
|
|
func (r ApiSearchRequest) TeamIds(teamIds interface{}) ApiSearchRequest {
|
|
r.teamIds = &teamIds
|
|
return r
|
|
}
|
|
|
|
// Unique League List Identifier
|
|
func (r ApiSearchRequest) LeagueListId(leagueListId interface{}) ApiSearchRequest {
|
|
r.leagueListId = &leagueListId
|
|
return r
|
|
}
|
|
|
|
// Whether or not a player is active
|
|
func (r ApiSearchRequest) Active(active interface{}) ApiSearchRequest {
|
|
r.active = &active
|
|
return r
|
|
}
|
|
|
|
// Complete and confirmed all biographical data
|
|
func (r ApiSearchRequest) Verified(verified interface{}) ApiSearchRequest {
|
|
r.verified = &verified
|
|
return r
|
|
}
|
|
|
|
// Whether or not a player is a rookie
|
|
func (r ApiSearchRequest) Rookie(rookie interface{}) ApiSearchRequest {
|
|
r.rookie = &rookie
|
|
return r
|
|
}
|
|
|
|
// Comma delimited list of Seasons of play
|
|
func (r ApiSearchRequest) Seasons(seasons interface{}) ApiSearchRequest {
|
|
r.seasons = &seasons
|
|
return r
|
|
}
|
|
|
|
// Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
|
|
func (r ApiSearchRequest) Fields(fields interface{}) ApiSearchRequest {
|
|
r.fields = &fields
|
|
return r
|
|
}
|
|
|
|
// Boolean value to specify wanting a person's name with accents or without
|
|
func (r ApiSearchRequest) Accent(accent interface{}) ApiSearchRequest {
|
|
r.accent = &accent
|
|
return r
|
|
}
|
|
|
|
// Number of results to return
|
|
func (r ApiSearchRequest) Limit(limit interface{}) ApiSearchRequest {
|
|
r.limit = &limit
|
|
return r
|
|
}
|
|
|
|
func (r ApiSearchRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.SearchExecute(r)
|
|
}
|
|
|
|
/*
|
|
Search Search for a player by name
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return ApiSearchRequest
|
|
*/
|
|
func (a *PersonAPIService) Search(ctx context.Context) ApiSearchRequest {
|
|
return ApiSearchRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *PersonAPIService) SearchExecute(r ApiSearchRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PersonAPIService.Search")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/api/v1/people/search"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.names != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "names", r.names, "", "")
|
|
}
|
|
if r.personIds != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "personIds", r.personIds, "", "")
|
|
}
|
|
if r.sportIds != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "sportIds", r.sportIds, "", "")
|
|
}
|
|
if r.leagueIds != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "leagueIds", r.leagueIds, "", "")
|
|
}
|
|
if r.teamIds != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "teamIds", r.teamIds, "", "")
|
|
}
|
|
if r.leagueListId != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "leagueListId", r.leagueListId, "", "")
|
|
}
|
|
if r.active != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "active", r.active, "", "")
|
|
}
|
|
if r.verified != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "verified", r.verified, "", "")
|
|
}
|
|
if r.rookie != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "rookie", r.rookie, "", "")
|
|
}
|
|
if r.seasons != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "seasons", r.seasons, "", "")
|
|
}
|
|
if r.fields != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "fields", r.fields, "", "")
|
|
}
|
|
if r.accent != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "accent", r.accent, "", "")
|
|
}
|
|
if r.limit != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "", "")
|
|
}
|
|
// 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 ApiStats3Request struct {
|
|
ctx context.Context
|
|
ApiService *PersonAPIService
|
|
personId interface{}
|
|
stats *interface{}
|
|
group *interface{}
|
|
season *interface{}
|
|
seasons *interface{}
|
|
sportId *interface{}
|
|
opposingTeamId *interface{}
|
|
opposingPlayerId *interface{}
|
|
metrics *interface{}
|
|
leagueId *interface{}
|
|
leagueListId *interface{}
|
|
sitCodes *interface{}
|
|
combineSits *interface{}
|
|
startDate *interface{}
|
|
endDate *interface{}
|
|
daysBack *interface{}
|
|
gamesBack *interface{}
|
|
limit *interface{}
|
|
eventType *interface{}
|
|
pitchType *interface{}
|
|
hitTrajectory *interface{}
|
|
batSide *interface{}
|
|
gameType *interface{}
|
|
groupBy *interface{}
|
|
accent *interface{}
|
|
fields *interface{}
|
|
}
|
|
|
|
// Type of statistics. Format: Individual, Team, Career, etc. Available types in /api/v1/statTypes
|
|
func (r ApiStats3Request) Stats(stats interface{}) ApiStats3Request {
|
|
r.stats = &stats
|
|
return r
|
|
}
|
|
|
|
// Category of statistic to return. Available types in /api/v1/statGroups
|
|
func (r ApiStats3Request) Group(group interface{}) ApiStats3Request {
|
|
r.group = &group
|
|
return r
|
|
}
|
|
|
|
// Season of play
|
|
func (r ApiStats3Request) Season(season interface{}) ApiStats3Request {
|
|
r.season = &season
|
|
return r
|
|
}
|
|
|
|
// Comma delimited list of Seasons of play
|
|
func (r ApiStats3Request) Seasons(seasons interface{}) ApiStats3Request {
|
|
r.seasons = &seasons
|
|
return r
|
|
}
|
|
|
|
// Top level organization of a sport
|
|
func (r ApiStats3Request) SportId(sportId interface{}) ApiStats3Request {
|
|
r.sportId = &sportId
|
|
return r
|
|
}
|
|
|
|
// A unique identifier for the opposing team. Must be used with Team ID
|
|
func (r ApiStats3Request) OpposingTeamId(opposingTeamId interface{}) ApiStats3Request {
|
|
r.opposingTeamId = &opposingTeamId
|
|
return r
|
|
}
|
|
|
|
// A unique identifier for the opposing team
|
|
func (r ApiStats3Request) OpposingPlayerId(opposingPlayerId interface{}) ApiStats3Request {
|
|
r.opposingPlayerId = &opposingPlayerId
|
|
return r
|
|
}
|
|
|
|
// Name of metric(s) for metric log stats. Available metrics in /api/v1/metrics
|
|
func (r ApiStats3Request) Metrics(metrics interface{}) ApiStats3Request {
|
|
r.metrics = &metrics
|
|
return r
|
|
}
|
|
|
|
// Unique League Identifier
|
|
func (r ApiStats3Request) LeagueId(leagueId interface{}) ApiStats3Request {
|
|
r.leagueId = &leagueId
|
|
return r
|
|
}
|
|
|
|
// Unique League List Identifier
|
|
func (r ApiStats3Request) LeagueListId(leagueListId interface{}) ApiStats3Request {
|
|
r.leagueListId = &leagueListId
|
|
return r
|
|
}
|
|
|
|
// Situation code for a given stat split.
|
|
func (r ApiStats3Request) SitCodes(sitCodes interface{}) ApiStats3Request {
|
|
r.sitCodes = &sitCodes
|
|
return r
|
|
}
|
|
|
|
// If true, gathers stats where all of the situational criteria are met. If false, returns stats where any of the situational criteria are met. Default: false
|
|
func (r ApiStats3Request) CombineSits(combineSits interface{}) ApiStats3Request {
|
|
r.combineSits = &combineSits
|
|
return r
|
|
}
|
|
|
|
// Start date for range of data (must be used with end date). Format: MM/DD/YYYY
|
|
func (r ApiStats3Request) StartDate(startDate interface{}) ApiStats3Request {
|
|
r.startDate = &startDate
|
|
return r
|
|
}
|
|
|
|
// End date for range of data (must be used with start date). Format: MM/DD/YYYY
|
|
func (r ApiStats3Request) EndDate(endDate interface{}) ApiStats3Request {
|
|
r.endDate = &endDate
|
|
return r
|
|
}
|
|
|
|
// Returns results from the last 'X' days (Starting from yesterday).
|
|
func (r ApiStats3Request) DaysBack(daysBack interface{}) ApiStats3Request {
|
|
r.daysBack = &daysBack
|
|
return r
|
|
}
|
|
|
|
// Returns results from the last 'X' games played.
|
|
func (r ApiStats3Request) GamesBack(gamesBack interface{}) ApiStats3Request {
|
|
r.gamesBack = &gamesBack
|
|
return r
|
|
}
|
|
|
|
// Number of results to return
|
|
func (r ApiStats3Request) Limit(limit interface{}) ApiStats3Request {
|
|
r.limit = &limit
|
|
return r
|
|
}
|
|
|
|
// Type of event
|
|
func (r ApiStats3Request) EventType(eventType interface{}) ApiStats3Request {
|
|
r.eventType = &eventType
|
|
return r
|
|
}
|
|
|
|
// Classification of pitch (fastball, curveball, etc...)
|
|
func (r ApiStats3Request) PitchType(pitchType interface{}) ApiStats3Request {
|
|
r.pitchType = &pitchType
|
|
return r
|
|
}
|
|
|
|
// Trajectory of hit (line drive, fly ball, etc...)
|
|
func (r ApiStats3Request) HitTrajectory(hitTrajectory interface{}) ApiStats3Request {
|
|
r.hitTrajectory = &hitTrajectory
|
|
return r
|
|
}
|
|
|
|
// Bat side of hitter
|
|
func (r ApiStats3Request) BatSide(batSide interface{}) ApiStats3Request {
|
|
r.batSide = &batSide
|
|
return r
|
|
}
|
|
|
|
// Type of Game. Available types in /api/v1/gameTypes
|
|
func (r ApiStats3Request) GameType(gameType interface{}) ApiStats3Request {
|
|
r.gameType = &gameType
|
|
return r
|
|
}
|
|
|
|
// Group stats by PLAYER, TEAM, SEASON, VENUE, SPORT or STAT_GROUP
|
|
func (r ApiStats3Request) GroupBy(groupBy interface{}) ApiStats3Request {
|
|
r.groupBy = &groupBy
|
|
return r
|
|
}
|
|
|
|
// Boolean value to specify wanting a person's name with accents or without
|
|
func (r ApiStats3Request) Accent(accent interface{}) ApiStats3Request {
|
|
r.accent = &accent
|
|
return r
|
|
}
|
|
|
|
// Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
|
|
func (r ApiStats3Request) Fields(fields interface{}) ApiStats3Request {
|
|
r.fields = &fields
|
|
return r
|
|
}
|
|
|
|
func (r ApiStats3Request) Execute() (*http.Response, error) {
|
|
return r.ApiService.Stats3Execute(r)
|
|
}
|
|
|
|
/*
|
|
Stats3 View a players stats
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param personId Unique Player Identifier. Format: 434538, 429665, etc
|
|
@return ApiStats3Request
|
|
*/
|
|
func (a *PersonAPIService) Stats3(ctx context.Context, personId interface{}) ApiStats3Request {
|
|
return ApiStats3Request{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
personId: personId,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *PersonAPIService) Stats3Execute(r ApiStats3Request) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PersonAPIService.Stats3")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/api/v1/people/{personId}/stats"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"personId"+"}", url.PathEscape(parameterValueToString(r.personId, "personId")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.stats == nil {
|
|
return nil, reportError("stats is required and must be specified")
|
|
}
|
|
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "stats", r.stats, "", "")
|
|
if r.group != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "group", r.group, "", "")
|
|
}
|
|
if r.season != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "season", r.season, "", "")
|
|
}
|
|
if r.seasons != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "seasons", r.seasons, "", "")
|
|
}
|
|
if r.sportId != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "sportId", r.sportId, "", "")
|
|
}
|
|
if r.opposingTeamId != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "opposingTeamId", r.opposingTeamId, "", "")
|
|
}
|
|
if r.opposingPlayerId != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "opposingPlayerId", r.opposingPlayerId, "", "")
|
|
}
|
|
if r.metrics != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "metrics", r.metrics, "", "")
|
|
}
|
|
if r.leagueId != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "leagueId", r.leagueId, "", "")
|
|
}
|
|
if r.leagueListId != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "leagueListId", r.leagueListId, "", "")
|
|
}
|
|
if r.sitCodes != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "sitCodes", r.sitCodes, "", "")
|
|
}
|
|
if r.combineSits != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "combineSits", r.combineSits, "", "")
|
|
}
|
|
if r.startDate != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "startDate", r.startDate, "", "")
|
|
}
|
|
if r.endDate != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "endDate", r.endDate, "", "")
|
|
}
|
|
if r.daysBack != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "daysBack", r.daysBack, "", "")
|
|
}
|
|
if r.gamesBack != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "gamesBack", r.gamesBack, "", "")
|
|
}
|
|
if r.limit != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "", "")
|
|
}
|
|
if r.eventType != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "eventType", r.eventType, "", "")
|
|
}
|
|
if r.pitchType != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "pitchType", r.pitchType, "", "")
|
|
}
|
|
if r.hitTrajectory != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "hitTrajectory", r.hitTrajectory, "", "")
|
|
}
|
|
if r.batSide != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "batSide", r.batSide, "", "")
|
|
}
|
|
if r.gameType != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "gameType", r.gameType, "", "")
|
|
}
|
|
if r.groupBy != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "groupBy", r.groupBy, "", "")
|
|
}
|
|
if r.accent != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "accent", r.accent, "", "")
|
|
}
|
|
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 ApiStatsMetricsRequest struct {
|
|
ctx context.Context
|
|
ApiService *PersonAPIService
|
|
personId interface{}
|
|
stats *interface{}
|
|
group *interface{}
|
|
season *interface{}
|
|
seasons *interface{}
|
|
sportId *interface{}
|
|
opposingTeamId *interface{}
|
|
opposingPlayerId *interface{}
|
|
metrics *interface{}
|
|
leagueId *interface{}
|
|
leagueListId *interface{}
|
|
sitCodes *interface{}
|
|
combineSits *interface{}
|
|
startDate *interface{}
|
|
endDate *interface{}
|
|
daysBack *interface{}
|
|
gamesBack *interface{}
|
|
limit *interface{}
|
|
eventType *interface{}
|
|
pitchType *interface{}
|
|
hitTrajectory *interface{}
|
|
batSide *interface{}
|
|
gameType *interface{}
|
|
groupBy *interface{}
|
|
accent *interface{}
|
|
fields *interface{}
|
|
}
|
|
|
|
// Type of statistics. Format: Individual, Team, Career, etc. Available types in /api/v1/statTypes
|
|
func (r ApiStatsMetricsRequest) Stats(stats interface{}) ApiStatsMetricsRequest {
|
|
r.stats = &stats
|
|
return r
|
|
}
|
|
|
|
// Category of statistic to return. Available types in /api/v1/statGroups
|
|
func (r ApiStatsMetricsRequest) Group(group interface{}) ApiStatsMetricsRequest {
|
|
r.group = &group
|
|
return r
|
|
}
|
|
|
|
// Season of play
|
|
func (r ApiStatsMetricsRequest) Season(season interface{}) ApiStatsMetricsRequest {
|
|
r.season = &season
|
|
return r
|
|
}
|
|
|
|
// Comma delimited list of Seasons of play
|
|
func (r ApiStatsMetricsRequest) Seasons(seasons interface{}) ApiStatsMetricsRequest {
|
|
r.seasons = &seasons
|
|
return r
|
|
}
|
|
|
|
// Top level organization of a sport
|
|
func (r ApiStatsMetricsRequest) SportId(sportId interface{}) ApiStatsMetricsRequest {
|
|
r.sportId = &sportId
|
|
return r
|
|
}
|
|
|
|
// A unique identifier for the opposing team. Must be used with Team ID
|
|
func (r ApiStatsMetricsRequest) OpposingTeamId(opposingTeamId interface{}) ApiStatsMetricsRequest {
|
|
r.opposingTeamId = &opposingTeamId
|
|
return r
|
|
}
|
|
|
|
// A unique identifier for the opposing team
|
|
func (r ApiStatsMetricsRequest) OpposingPlayerId(opposingPlayerId interface{}) ApiStatsMetricsRequest {
|
|
r.opposingPlayerId = &opposingPlayerId
|
|
return r
|
|
}
|
|
|
|
// Name of metric(s) for metric log stats. Available metrics in /api/v1/metrics
|
|
func (r ApiStatsMetricsRequest) Metrics(metrics interface{}) ApiStatsMetricsRequest {
|
|
r.metrics = &metrics
|
|
return r
|
|
}
|
|
|
|
// Unique League Identifier
|
|
func (r ApiStatsMetricsRequest) LeagueId(leagueId interface{}) ApiStatsMetricsRequest {
|
|
r.leagueId = &leagueId
|
|
return r
|
|
}
|
|
|
|
// Unique League List Identifier
|
|
func (r ApiStatsMetricsRequest) LeagueListId(leagueListId interface{}) ApiStatsMetricsRequest {
|
|
r.leagueListId = &leagueListId
|
|
return r
|
|
}
|
|
|
|
// Situation code for a given stat split.
|
|
func (r ApiStatsMetricsRequest) SitCodes(sitCodes interface{}) ApiStatsMetricsRequest {
|
|
r.sitCodes = &sitCodes
|
|
return r
|
|
}
|
|
|
|
// If true, gathers stats where all of the situational criteria are met. If false, returns stats where any of the situational criteria are met. Default: false
|
|
func (r ApiStatsMetricsRequest) CombineSits(combineSits interface{}) ApiStatsMetricsRequest {
|
|
r.combineSits = &combineSits
|
|
return r
|
|
}
|
|
|
|
// Start date for range of data (must be used with end date). Format: MM/DD/YYYY
|
|
func (r ApiStatsMetricsRequest) StartDate(startDate interface{}) ApiStatsMetricsRequest {
|
|
r.startDate = &startDate
|
|
return r
|
|
}
|
|
|
|
// End date for range of data (must be used with start date). Format: MM/DD/YYYY
|
|
func (r ApiStatsMetricsRequest) EndDate(endDate interface{}) ApiStatsMetricsRequest {
|
|
r.endDate = &endDate
|
|
return r
|
|
}
|
|
|
|
// Returns results from the last 'X' days (Starting from yesterday).
|
|
func (r ApiStatsMetricsRequest) DaysBack(daysBack interface{}) ApiStatsMetricsRequest {
|
|
r.daysBack = &daysBack
|
|
return r
|
|
}
|
|
|
|
// Returns results from the last 'X' games played.
|
|
func (r ApiStatsMetricsRequest) GamesBack(gamesBack interface{}) ApiStatsMetricsRequest {
|
|
r.gamesBack = &gamesBack
|
|
return r
|
|
}
|
|
|
|
// Number of results to return
|
|
func (r ApiStatsMetricsRequest) Limit(limit interface{}) ApiStatsMetricsRequest {
|
|
r.limit = &limit
|
|
return r
|
|
}
|
|
|
|
// Type of event
|
|
func (r ApiStatsMetricsRequest) EventType(eventType interface{}) ApiStatsMetricsRequest {
|
|
r.eventType = &eventType
|
|
return r
|
|
}
|
|
|
|
// Classification of pitch (fastball, curveball, etc...)
|
|
func (r ApiStatsMetricsRequest) PitchType(pitchType interface{}) ApiStatsMetricsRequest {
|
|
r.pitchType = &pitchType
|
|
return r
|
|
}
|
|
|
|
// Trajectory of hit (line drive, fly ball, etc...)
|
|
func (r ApiStatsMetricsRequest) HitTrajectory(hitTrajectory interface{}) ApiStatsMetricsRequest {
|
|
r.hitTrajectory = &hitTrajectory
|
|
return r
|
|
}
|
|
|
|
// Bat side of hitter
|
|
func (r ApiStatsMetricsRequest) BatSide(batSide interface{}) ApiStatsMetricsRequest {
|
|
r.batSide = &batSide
|
|
return r
|
|
}
|
|
|
|
// Type of Game. Available types in /api/v1/gameTypes
|
|
func (r ApiStatsMetricsRequest) GameType(gameType interface{}) ApiStatsMetricsRequest {
|
|
r.gameType = &gameType
|
|
return r
|
|
}
|
|
|
|
// Group stats by PLAYER, TEAM, SEASON, VENUE, SPORT or STAT_GROUP
|
|
func (r ApiStatsMetricsRequest) GroupBy(groupBy interface{}) ApiStatsMetricsRequest {
|
|
r.groupBy = &groupBy
|
|
return r
|
|
}
|
|
|
|
// Boolean value to specify wanting a person's name with accents or without
|
|
func (r ApiStatsMetricsRequest) Accent(accent interface{}) ApiStatsMetricsRequest {
|
|
r.accent = &accent
|
|
return r
|
|
}
|
|
|
|
// Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
|
|
func (r ApiStatsMetricsRequest) Fields(fields interface{}) ApiStatsMetricsRequest {
|
|
r.fields = &fields
|
|
return r
|
|
}
|
|
|
|
func (r ApiStatsMetricsRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.StatsMetricsExecute(r)
|
|
}
|
|
|
|
/*
|
|
StatsMetrics View a player's stat metrics
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param personId Unique Player Identifier. Format: 434538, 429665, etc
|
|
@return ApiStatsMetricsRequest
|
|
*/
|
|
func (a *PersonAPIService) StatsMetrics(ctx context.Context, personId interface{}) ApiStatsMetricsRequest {
|
|
return ApiStatsMetricsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
personId: personId,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *PersonAPIService) StatsMetricsExecute(r ApiStatsMetricsRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PersonAPIService.StatsMetrics")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/api/v1/people/{personId}/stats/metrics"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"personId"+"}", url.PathEscape(parameterValueToString(r.personId, "personId")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.stats == nil {
|
|
return nil, reportError("stats is required and must be specified")
|
|
}
|
|
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "stats", r.stats, "", "")
|
|
if r.group != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "group", r.group, "", "")
|
|
}
|
|
if r.season != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "season", r.season, "", "")
|
|
}
|
|
if r.seasons != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "seasons", r.seasons, "", "")
|
|
}
|
|
if r.sportId != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "sportId", r.sportId, "", "")
|
|
}
|
|
if r.opposingTeamId != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "opposingTeamId", r.opposingTeamId, "", "")
|
|
}
|
|
if r.opposingPlayerId != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "opposingPlayerId", r.opposingPlayerId, "", "")
|
|
}
|
|
if r.metrics != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "metrics", r.metrics, "", "")
|
|
}
|
|
if r.leagueId != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "leagueId", r.leagueId, "", "")
|
|
}
|
|
if r.leagueListId != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "leagueListId", r.leagueListId, "", "")
|
|
}
|
|
if r.sitCodes != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "sitCodes", r.sitCodes, "", "")
|
|
}
|
|
if r.combineSits != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "combineSits", r.combineSits, "", "")
|
|
}
|
|
if r.startDate != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "startDate", r.startDate, "", "")
|
|
}
|
|
if r.endDate != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "endDate", r.endDate, "", "")
|
|
}
|
|
if r.daysBack != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "daysBack", r.daysBack, "", "")
|
|
}
|
|
if r.gamesBack != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "gamesBack", r.gamesBack, "", "")
|
|
}
|
|
if r.limit != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "", "")
|
|
}
|
|
if r.eventType != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "eventType", r.eventType, "", "")
|
|
}
|
|
if r.pitchType != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "pitchType", r.pitchType, "", "")
|
|
}
|
|
if r.hitTrajectory != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "hitTrajectory", r.hitTrajectory, "", "")
|
|
}
|
|
if r.batSide != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "batSide", r.batSide, "", "")
|
|
}
|
|
if r.gameType != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "gameType", r.gameType, "", "")
|
|
}
|
|
if r.groupBy != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "groupBy", r.groupBy, "", "")
|
|
}
|
|
if r.accent != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "accent", r.accent, "", "")
|
|
}
|
|
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
|
|
}
|