Module: SportsDataApi::Nhl

Extended by:
Request
Defined in:
lib/sports_data_api/nhl.rb,
lib/sports_data_api/nhl/game.rb,
lib/sports_data_api/nhl/team.rb,
lib/sports_data_api/nhl/games.rb,
lib/sports_data_api/nhl/teams.rb,
lib/sports_data_api/nhl/venue.rb,
lib/sports_data_api/nhl/player.rb,
lib/sports_data_api/nhl/season.rb,
lib/sports_data_api/nhl/broadcast.rb

Defined Under Namespace

Classes: Broadcast, Game, Games, Player, Season, Team, Teams, Venue

Constant Summary collapse

API_VERSION =
5
BASE_URL =
'https://api.sportradar.us/nhl/%{access_level}/v%{version}/en'
DIR =
File.join(File.dirname(__FILE__), 'nhl')
SPORT =
:nhl

Class Method Summary collapse

Methods included from Request

response_json, response_xml, response_xml_xpath

Class Method Details

.daily(year, month, day) ⇒ Object

Fetches NHL daily schedule for a given date



49
50
51
# File 'lib/sports_data_api/nhl.rb', line 49

def daily(year, month, day)
  Games.new(response_json("/games/#{year}/#{month}/#{day}/schedule.json"))
end

.game_summary(game_id) ⇒ Object

Fetches NHL game summary for a given game



37
38
39
# File 'lib/sports_data_api/nhl.rb', line 37

def game_summary(game_id)
  Game.new(json: response_json("/games/#{game_id}/summary.json"))
end

.schedule(year, season) ⇒ Object

Fetches NHL season schedule for a given year and season

Raises:



22
23
24
25
26
27
# File 'lib/sports_data_api/nhl.rb', line 22

def schedule(year, season)
  season = season.to_s.upcase.to_sym
  raise Error.new("#{season} is not a valid season") unless Season.valid?(season)

  Season.new(response_json("/games/#{year}/#{season}/schedule.json"))
end

.team_roster(team_id) ⇒ Object

Fetches NHL team roster



31
32
33
# File 'lib/sports_data_api/nhl.rb', line 31

def team_roster(team_id)
  Team.new(response_json("/teams/#{team_id}/profile.json"))
end

.teamsObject

Fetches all NHL teams



43
44
45
# File 'lib/sports_data_api/nhl.rb', line 43

def teams
  Teams.new(response_json('/league/hierarchy.json'))
end