Documentation
¶
Index ¶
- Constants
- func DenverLocation() *time.Location
- type Client
- func (c *Client) GetGameLiveStatus(date string) ([]GameLiveStatus, error)
- func (c *Client) GetGamesSince(date string) ([]GameResult, error)
- func (c *Client) GetHeadToHead(opponentID int) (*H2HRecord, error)
- func (c *Client) GetPitcherStats(playerID int) (*PitcherStats, error)
- func (c *Client) GetSeasonResults() ([]GameResult, error)
- func (c *Client) GetTeamRecord() (*TeamRecord, error)
- func (c *Client) GetTodayGame() (*Game, error)
- func (c *Client) GetTodayGames() ([]*Game, error)
- type Game
- func (g *Game) FormatGameTime() string
- func (g *Game) GameTimeMST() time.Time
- func (g *Game) HasProbablePitchers() bool
- func (g *Game) IsPlayable() bool
- func (g *Game) IsUpcoming(now ...time.Time) bool
- func (g *Game) Opponent() TeamInfo
- func (g *Game) OpponentID() int
- func (g *Game) OpponentPitcher() *PitcherInfo
- func (g *Game) RockiesPitcher() *PitcherInfo
- func (g *Game) RockiesTeam() TeamInfo
- type GameLiveStatus
- type GameProvider
- type GameResult
- type H2HRecord
- type PitcherInfo
- type PitcherStats
- type TeamInfo
- type TeamRecord
Constants ¶
View Source
const ( RockiesID = 115 NLLeagueID = 104 )
Variables ¶
This section is empty.
Functions ¶
func DenverLocation ¶
DenverLocation returns the America/Denver timezone.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements GameProvider using the MLB Stats API.
func (*Client) GetGameLiveStatus ¶ added in v0.6.3
func (c *Client) GetGameLiveStatus(date string) ([]GameLiveStatus, error)
func (*Client) GetGamesSince ¶
func (c *Client) GetGamesSince(date string) ([]GameResult, error)
func (*Client) GetPitcherStats ¶
func (c *Client) GetPitcherStats(playerID int) (*PitcherStats, error)
func (*Client) GetSeasonResults ¶ added in v0.6.1
func (c *Client) GetSeasonResults() ([]GameResult, error)
GetSeasonResults returns every completed regular-season Rockies game for the current season.
func (*Client) GetTeamRecord ¶
func (c *Client) GetTeamRecord() (*TeamRecord, error)
func (*Client) GetTodayGame ¶
func (*Client) GetTodayGames ¶
type Game ¶
type Game struct {
GamePk int
GameDateTime time.Time
OfficialDate string // MLB's canonical game date "2006-01-02"; authoritative over the wall clock
Status string // "Preview", "Live", "Final" (abstractGameState)
DetailedState string // "Scheduled", "Postponed", "Cancelled", etc.
Reason string // reason for postponement/cancellation
RescheduleGameDate string // official date a postponed game was moved to, if any
HomeTeam TeamInfo
AwayTeam TeamInfo
Venue string
IsHome bool // true if Rockies are the home team
GameNumber int // 1 or 2 for double-headers
DoubleHeader string // "Y" (straight), "S" (split), "N" (not)
}
Game represents a single Rockies game.
func (*Game) FormatGameTime ¶
func (*Game) GameTimeMST ¶
func (*Game) HasProbablePitchers ¶
func (*Game) IsPlayable ¶
func (*Game) OpponentID ¶
func (*Game) OpponentPitcher ¶
func (g *Game) OpponentPitcher() *PitcherInfo
func (*Game) RockiesPitcher ¶
func (g *Game) RockiesPitcher() *PitcherInfo
func (*Game) RockiesTeam ¶
type GameLiveStatus ¶ added in v0.6.3
type GameLiveStatus struct {
GamePk int
Status string // "Preview", "Live", "Final"
CurrentInning int
InningState string // "Top", "Middle", "Bottom", "End"
}
GameLiveStatus represents the live state of a game including inning info.
type GameProvider ¶
type GameProvider interface {
GetTodayGame() (*Game, error)
GetTodayGames() ([]*Game, error)
GetTeamRecord() (*TeamRecord, error)
GetPitcherStats(playerID int) (*PitcherStats, error)
GetHeadToHead(opponentID int) (*H2HRecord, error)
GetGamesSince(date string) ([]GameResult, error)
GetGameLiveStatus(date string) ([]GameLiveStatus, error)
}
GameProvider is the interface for fetching MLB data. All business logic depends on this interface, making it trivially mockable in tests.
type GameResult ¶
type GameResult struct {
GamePk int `json:"gamePk"`
Date string `json:"date"` // MLB official date "2006-01-02"
GameDateTime time.Time `json:"gameDateTime"` // first-pitch time (UTC)
OpponentID int `json:"opponentId"`
Opponent string `json:"opponent"`
IsHome bool `json:"isHome"`
RockiesScore int `json:"rockiesScore"`
OppScore int `json:"oppScore"`
Won bool `json:"won"`
Status string `json:"status"`
GameNumber int `json:"gameNumber,omitempty"`
}
type PitcherInfo ¶
type PitcherStats ¶
type PitcherStats struct {
PlayerID int
FullName string
ERA float64
WHIP float64
Wins int
Losses int
StrikeOuts int
InningsPitched float64
GamesStarted int
}
PitcherStats represents season pitching stats for a single pitcher.
type TeamInfo ¶
type TeamInfo struct {
ID int
Name string
Wins int
Losses int
WinPct string
ProbablePitcher *PitcherInfo
}
func (TeamInfo) WinLossString ¶
type TeamRecord ¶
type TeamRecord struct {
Wins int
Losses int
WinningPercentage float64
RunsScored int
RunsAllowed int
RunDifferential int
StreakCode string // e.g. "W3", "L2"
HomeWins int
HomeLosses int
AwayWins int
AwayLosses int
Last10Wins int
Last10Losses int
}
TeamRecord represents current season standings for the Rockies.
Click to show internal directories.
Click to hide internal directories.