nhl

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ANA ...
	ANA = "ANA"
	// ARI ...
	ARI = "ARI"
	// BOS ...
	BOS = "BOS"
	// BUF ...
	BUF = "BUF"
	// CAR ...
	CAR = "CAR"
	// CBJ ...
	CBJ = "CBJ"
	// CGY ...
	CGY = "CGY"
	// CHI ...
	CHI = "CHI"
	// COL ...
	COL = "COL"
	// DAL ...
	DAL = "DAL"
	// DET ...
	DET = "DET"
	// EDM ...
	EDM = "EDM"
	// FLA ...
	FLA = "FLA"
	// LAK ...
	LAK = "LAK"
	// MIN ...
	MIN = "MIN"
	// MTL ...
	MTL = "MTL"
	// NJD ...
	NJD = "NJD"
	// NSH ...
	NSH = "NSH"
	// NYI ...
	NYI = "NYI"
	// NYR ...
	NYR = "NYR"
	// OTT ...
	OTT = "OTT"
	// PHI ...
	PHI = "PHI"
	// PIT ...
	PIT = "PIT"
	// SJS ...
	SJS = "SJS"
	// STL ...
	STL = "STL"
	// TBL ...
	TBL = "TBL"
	// TOR ...
	TOR = "TOR"
	// VAN ...
	VAN = "VAN"
	// VGK ...
	VGK = "VGK"
	// WPG ...
	WPG = "WPG"
	// WSH ...
	WSH = "WSH"
)
View Source
const (

	// DateFormat ...
	DateFormat = "2006-01-02"
)

Variables

View Source
var ALL = []string{ANA, ARI, BOS, BUF, CAR, CBJ, CGY, CHI, COL, DAL, DET, EDM, FLA, LAK, MIN, MTL, NJD, NSH, NYI, NYR, OTT, PHI, PIT, SJS, STL, TBL, TOR, VAN, VGK, WPG, WSH}

ALL is a list of all teams in the league

Functions

func GetLiveGame

func GetLiveGame(ctx context.Context, link string) (sportboard.Game, error)

GetLiveGame is a LiveGameGetter

func GetLogo(logoKey string, logoConf *logo.Config, bounds image.Rectangle, logoSources map[string]image.Image) (*logo.Logo, error)

GetLogo is a generic logo getter. Useful for testing

Types

type Game

type Game struct {
	GameGetter LiveGameGetter
	ID         int    `json:"gamePk"`
	Link       string `json:"link"`
	Teams      *struct {
		Away *gameTeam `json:"away"`
		Home *gameTeam `json:"home"`
	} `json:"teams"`
	GameTime time.Time
	GameDate string `json:"gameDate"`
	GameData *struct {
		DateTime *struct {
			DateTime string `json:"datetime,omitempty"`
		} `json:"dateTime,omitempty"`
		Status *struct {
			AbstractGameState string `json:"abstractGameState,omitempty"`
			DetailedState     string `json:"detailedState,omitempty"`
		} `json:"status,omitempty"`
	} `json:"gameData,omitempty"`
	LiveData *struct {
		Linescore *struct {
			Teams *struct {
				Home *gameTeam `json:"home"`
				Away *gameTeam `json:"away"`
			} `json:"teams"`
			CurrentPeriod              int    `json:"currentPeriod,omitempty"`
			CurrentPeriodOrdinal       string `json:"currentPeriodOrdinal"`
			CurrentPeriodTimeRemaining string `json:"currentPeriodTimeRemaining,omitempty"`
		} `json:"linescore"`
	} `json:"liveData"`
}

Game implements sportboard.Game

func (*Game) AwayTeam

func (g *Game) AwayTeam() (sportboard.Team, error)

AwayTeam ...

func (*Game) GetClock

func (g *Game) GetClock() (string, error)

GetClock ...

func (*Game) GetID

func (g *Game) GetID() int

GetID ...

func (g *Game) GetLink() (string, error)

GetLink ...

func (*Game) GetQuarter

func (g *Game) GetQuarter() (string, error)

GetQuarter ...

func (*Game) GetStartTime

func (g *Game) GetStartTime(ctx context.Context) (time.Time, error)

GetStartTime ...

func (*Game) GetUpdate

func (g *Game) GetUpdate(ctx context.Context) (sportboard.Game, error)

GetUpdate ...

func (*Game) HomeTeam

func (g *Game) HomeTeam() (sportboard.Team, error)

HomeTeam ...

func (*Game) IsComplete

func (g *Game) IsComplete() (bool, error)

IsComplete ...

func (*Game) IsLive

func (g *Game) IsLive() (bool, error)

IsLive ...

type LiveGameGetter

type LiveGameGetter func(ctx context.Context, link string) (sportboard.Game, error)

LiveGameGetter retrieves a live game from a game link

type NHL

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

NHL implements sportboard.API

func New

func New(ctx context.Context, logger *log.Logger) (*NHL, error)

New ...

func (*NHL) AllTeamAbbreviations

func (n *NHL) AllTeamAbbreviations() []string

AllTeamAbbreviations ...

func (*NHL) DateStr

func (n *NHL) DateStr(d time.Time) string

DateStr ...

func (*NHL) Games

func (n *NHL) Games(dateStr string) ([]*Game, error)

Games ...

func (n *NHL) GetLogo(logoKey string, logoConf *logo.Config, bounds image.Rectangle) (*logo.Logo, error)

GetLogo ...

func (*NHL) GetScheduledGames

func (n *NHL) GetScheduledGames(ctx context.Context, date time.Time) ([]sportboard.Game, error)

GetScheduledGames ...

func (*NHL) GetTeams

func (n *NHL) GetTeams(ctx context.Context) ([]sportboard.Team, error)

GetTeams ...

func (*NHL) HTTPPathPrefix

func (n *NHL) HTTPPathPrefix() string

HTTPPathPrefix returns the prefix of HTTP calls to this board. i.e. /nhl/foo

func (*NHL) League

func (n *NHL) League() string

League ...

func (*NHL) TeamFromAbbreviation

func (n *NHL) TeamFromAbbreviation(ctx context.Context, abbreviation string) (sportboard.Team, error)

TeamFromAbbreviation ...

func (*NHL) UpdateGames

func (n *NHL) UpdateGames(ctx context.Context, dateStr string) error

UpdateGames ...

func (*NHL) UpdateTeams

func (n *NHL) UpdateTeams(ctx context.Context) error

UpdateTeams ...

type Team

type Team struct {
	ID               int    `json:"id"`
	Name             string `json:"name"`
	Abbreviation     string `json:"abbreviation"`
	NextGameSchedule *struct {
		Dates []*struct {
			Games []*Game `json:"games"`
		} `json:"dates"`
	} `json:"nextGameSchedule,omitempty"`
	// contains filtered or unexported fields
}

Team implements sportboard.Team

func GetTeams

func GetTeams(ctx context.Context) ([]*Team, error)

GetTeams ...

func (*Team) GetAbbreviation

func (t *Team) GetAbbreviation() string

GetAbbreviation ...

func (*Team) GetID

func (t *Team) GetID() int

GetID ...

func (*Team) GetName

func (t *Team) GetName() string

GetName ...

func (*Team) Score

func (t *Team) Score() int

Score ...

Jump to

Keyboard shortcuts

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