client

package
v0.0.0-...-af7f737 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

README

Go API client for client

This is an attempt to encode the CFL API using Swagger Spec.

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 1.32
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context
go get github.com/antihax/optional

Put the package under your project folder and add the following in import:

import "./client"

Documentation for API Endpoints

All URIs are relative to https://api.cfl.ca

Class Method HTTP request Description
GamesApi GetGameById Get /v1/games/{season}/game/{gameId} Get data for a specific game
GamesApi GetGames Get /v1/games/{season} Get a list of all games in a particular season

Documentation For Models

Documentation For Authorization

api_key

  • Type: API key

Example

auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{
	Key: "APIKEY",
	Prefix: "Bearer", // Omit if not necessary.
})
r, err := client.Service.Operation(auth, args)

Author

tech@cfl.ca

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.
	ContextOAuth2 = contextKey("token")

	// ContextBasicAuth takes BasicAuth as authentication for the request.
	ContextBasicAuth = contextKey("basic")

	// ContextAccessToken takes a string oauth2 access token as authentication for the request.
	ContextAccessToken = contextKey("accesstoken")

	// ContextAPIKey takes an APIKey as authentication for the request
	ContextAPIKey = contextKey("apikey")
)

Functions

func CacheExpires

func CacheExpires(r *http.Response) time.Time

CacheExpires helper function to determine remaining time before repeating a request.

Types

type APIClient

type APIClient struct {
	GamesApi *GamesApiService
	// contains filtered or unexported fields
}

APIClient manages communication with the CFL API API v1.32 In most cases there should be only one, shared, APIClient.

func NewAPIClient

func NewAPIClient(cfg *Configuration) *APIClient

NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.

func (*APIClient) ChangeBasePath

func (c *APIClient) ChangeBasePath(path string)

Change base path to allow switching to mocks

type APIKey

type APIKey struct {
	Key    string
	Prefix string
}

APIKey provides API key based authentication to a request passed via context using ContextAPIKey

type APIResponse

type APIResponse struct {
	*http.Response `json:"-"`
	Message        string `json:"message,omitempty"`
	// Operation is the name of the OpenAPI operation.
	Operation string `json:"operation,omitempty"`
	// RequestURL is the request URL. This value is always available, even if the
	// embedded *http.Response is nil.
	RequestURL string `json:"url,omitempty"`
	// Method is the HTTP method used for the request.  This value is always
	// available, even if the embedded *http.Response is nil.
	Method string `json:"method,omitempty"`
	// Payload holds the contents of the response body (which may be nil or empty).
	// This is provided here as the raw response.Body() reader will have already
	// been drained.
	Payload []byte `json:"-"`
}

func NewAPIResponse

func NewAPIResponse(r *http.Response) *APIResponse

func NewAPIResponseWithError

func NewAPIResponseWithError(errorMessage string) *APIResponse

type ApiResponse

type ApiResponse struct {
	Code    int32  `json:"code,omitempty"`
	Type    string `json:"type,omitempty"`
	Message string `json:"message,omitempty"`
}

type BasicAuth

type BasicAuth struct {
	UserName string `json:"userName,omitempty"`
	Password string `json:"password,omitempty"`
}

BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth

type CoinToss

type CoinToss struct {
	CoinTossWinner string `json:"coin_toss_winner,omitempty"`
	// A free-form string that contains information on the winner of the game-starting coin toss, and what the team elected to do. The structure of this value is not normalized and as such should be used programmatically with caution.
	CoinTossWinnerElection string `json:"coin_toss_winner_election,omitempty"`
}

type Configuration

type Configuration struct {
	BasePath      string            `json:"basePath,omitempty"`
	Host          string            `json:"host,omitempty"`
	Scheme        string            `json:"scheme,omitempty"`
	DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
	UserAgent     string            `json:"userAgent,omitempty"`
	HTTPClient    *http.Client
}

func NewConfiguration

func NewConfiguration() *Configuration

func (*Configuration) AddDefaultHeader

func (c *Configuration) AddDefaultHeader(key string, value string)

type EventStatus

type EventStatus struct {
	// An integer value indicating the current status of the game. Possible values are: 1: Pre-Game 2: In-Progress 4: Final 9: Cancelled
	EventStatusId int32  `json:"event_status_id,omitempty"`
	Name          string `json:"name,omitempty"`
	// A Boolean value indicating if play is currently live in this game. If play is live at the time of the API request, the value returned is true; else it is false.
	IsActive bool `json:"is_active,omitempty"`
	// If this game is in progress, contains an integer value indicating the current quarter of play. Contains null if the game is not in play.
	Quarter int32 `json:"quarter,omitempty"`
	// If this game is in progress, contains an integer value indicating the last recorded minute value of the game clock. Contains null if the game is not in play.
	Minutes int32 `json:"minutes,omitempty"`
	// If this game is in progress, contains an integer value indicating the last recorded second value of the game clock. Contains null if the game is not in play.
	Seconds int32 `json:"seconds,omitempty"`
	// If this game is in progress, contains an integer value indicating the down of the last recorded play. Contains null if the game is not in play.
	Down int32 `json:"down,omitempty"`
	// If this game is in progress, contains an integer value indicating the last recorded number of yards to a first down. Contains null if the game is not in play.
	YardsToGo int32 `json:"yards_to_go,omitempty"`
}

type EventType

type EventType struct {
	// An integer value indicating the type of game played. Possible values are: 0: Preseason 1: Regular Season 2: Playoffs 3: Grey Cup
	EventTypeId int32  `json:"event_type_id,omitempty"`
	Name        string `json:"name,omitempty"`
	// An string value indicating the formal title of the game. Possible values can include: Blank / No value Eastern Semi-Final Western Semi-Final Eastern Final Western Final XXXth Grey Cup
	Title string `json:"title,omitempty"`
}

type Filter

type Filter struct {
	Field    string `json:"field,omitempty"`
	Operator string `json:"operator,omitempty"`
	Operand  string `json:"operand,omitempty"`
}

type Game

type Game struct {
	GameId       int32        `json:"game_id,omitempty"`
	DateStart    time.Time    `json:"date_start,omitempty"`
	GameNumber   int32        `json:"game_number,omitempty"`
	Week         int32        `json:"week,omitempty"`
	Season       int32        `json:"season,omitempty"`
	Attendance   int32        `json:"attendance,omitempty"`
	GameDuration int32        `json:"game_duration,omitempty"`
	EventType    EventType    `json:"event_type,omitempty"`
	EventStatus  EventStatus  `json:"event_status,omitempty"`
	Venue        Venue        `json:"venue,omitempty"`
	Weather      Weather      `json:"weather,omitempty"`
	CoinToss     CoinToss     `json:"coin_toss,omitempty"`
	TicketsUrl   string       `json:"tickets_url,omitempty"`
	Team1        Team         `json:"team_1,omitempty"`
	Team2        Team         `json:"team_2,omitempty"`
	PlayByPlay   []PlayByPlay `json:"play_by_play,omitempty"`
}

type Games

type Games struct {
	Data []Game `json:"data,omitempty"`
}

type GamesApiService

type GamesApiService service

func (*GamesApiService) GetGameById

func (a *GamesApiService) GetGameById(ctx context.Context, season int32, gameId int32, localVarOptionals *GetGameByIdOpts) (Games, *http.Response, error)

func (*GamesApiService) GetGames

func (a *GamesApiService) GetGames(ctx context.Context, season int32, localVarOptionals *GetGamesOpts) (Games, *http.Response, error)

type GenericOpenAPIError

type GenericOpenAPIError struct {
	// contains filtered or unexported fields
}

GenericOpenAPIError Provides access to the body, error and model on returned errors.

func (GenericOpenAPIError) Body

func (e GenericOpenAPIError) Body() []byte

Body returns the raw bytes of the response

func (GenericOpenAPIError) Error

func (e GenericOpenAPIError) Error() string

Error returns non-empty string if there was an error.

func (GenericOpenAPIError) Model

func (e GenericOpenAPIError) Model() interface{}

Model returns the unpacked model of the error

type GetGameByIdOpts

type GetGameByIdOpts struct {
	Include optional.Interface
	Sort    optional.Interface
	Filter  optional.Interface
	Page    optional.Interface
}

type GetGamesOpts

type GetGamesOpts struct {
	Include optional.Interface
	Sort    optional.Interface
	Filter  optional.Interface
	Page    optional.Interface
}

type Include

type Include string
const (
	BOXSCORE     Include = "boxscore"
	PLAY_BY_PLAY Include = "play_by_play"
	ROSTERS      Include = "rosters"
	PENALTIES    Include = "penalties"
	PLAY_REVIEWS Include = "play_reviews"
)

List of Include

type LineScore

type LineScore struct {
	Quarter int32 `json:"quarter,omitempty"`
	Score   int32 `json:"score,omitempty"`
}

type OtLineScore

type OtLineScore struct {
	Quarter string `json:"quarter,omitempty"`
	Score   int32  `json:"score,omitempty"`
}

type OverTimeLineScore

type OverTimeLineScore struct {
	Quarter string `json:"quarter,omitempty"`
	Score   int32  `json:"score,omitempty"`
}

type Page

type Page struct {
	Number int32 `json:"number,omitempty"`
	Size   int32 `json:"size,omitempty"`
}

type PlayByPlay

type PlayByPlay struct {
	PlayId                         int32  `json:"play_id,omitempty"`
	PlaySequence                   int32  `json:"play_sequence,omitempty"`
	Quarter                        int32  `json:"quarter,omitempty"`
	PlayClockStart                 string `json:"play_clock_start,omitempty"`
	PlayClockStartInSecs           int32  `json:"play_clock_start_in_secs,omitempty"`
	FieldPositionStart             string `json:"field_position_start,omitempty"`
	FieldPositionEnd               string `json:"field_position_end,omitempty"`
	Down                           int32  `json:"down,omitempty"`
	YardsToGo                      int32  `json:"yards_to_go,omitempty"`
	IsInRedZone                    bool   `json:"is_in_red_zone,omitempty"`
	TeamHomeScore                  int32  `json:"team_home_score,omitempty"`
	TeamVisitorScore               int32  `json:"team_visitor_score,omitempty"`
	PlayTypeId                     int32  `json:"play_type_id,omitempty"`
	PlayTypeDescription            string `json:"play_type_description,omitempty"`
	PlayResultTypeId               int32  `json:"play_result_type_id,omitempty"`
	PlayResultTypeDescription      string `json:"play_result_type_description,omitempty"`
	PlayResultYards                int32  `json:"play_result_yards,omitempty"`
	PlayResultPoints               int32  `json:"play_result_points,omitempty"`
	PlaySuccessId                  int32  `json:"play_success_id,omitempty"`
	PlaySuccessDescription         string `json:"play_success_description,omitempty"`
	PlayChangeOfPossessionOccurred bool   `json:"play_change_of_possession_occurred,omitempty"`
	TeamAbbreviation               string `json:"team_abbreviation,omitempty"`
	TeamId                         int32  `json:"team_id,omitempty"`
	PlaySummary                    string `json:"play_summary,omitempty"`
}

type Sort

type Sort string
const (
	DATE_START  Sort = "date_start"
	SEASON      Sort = "season"
	WEEK        Sort = "week"
	TEMPERATURE Sort = "temperature"
	ATTENDANCE  Sort = "attendance"
	TEAM_1      Sort = "team_1"
	TEAM_2      Sort = "team_2"
)

List of Sort

type Team

type Team struct {
	TeamId       int32                    `json:"team_id,omitempty"`
	Location     string                   `json:"location,omitempty"`
	Nickname     string                   `json:"nickname,omitempty"`
	Abbreviation string                   `json:"abbreviation,omitempty"`
	Score        int32                    `json:"score,omitempty"`
	VenueId      int32                    `json:"venue_id,omitempty"`
	Linescores   []map[string]interface{} `json:"linescores,omitempty"`
	IsAtHome     bool                     `json:"is_at_home,omitempty"`
	IsWinner     bool                     `json:"is_winner,omitempty"`
}

type Venue

type Venue struct {
	// A unique numeric value assigned to the stadium / venue the game is held within.
	VenueId int32 `json:"venue_id,omitempty"`
	// The name of the stadium / venue the game is held within.
	Name string `json:"name,omitempty"`
}

type Weather

type Weather struct {
	// An integer value indicating the temperature taken at the stadium / venue the game is held at. Note that this value can be zero or negative.
	Temperature     int32  `json:"temperature,omitempty"`
	Sky             string `json:"sky,omitempty"`
	WindSpeed       string `json:"wind_speed,omitempty"`
	WindDirection   string `json:"wind_direction,omitempty"`
	FieldConditions string `json:"field_conditions,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL