Class: Celly::Standings

Inherits:
Object
  • Object
show all
Defined in:
lib/celly/standings.rb

Constant Summary collapse

BASE_URL =
'https://statsapi.web.nhl.com/api/v1'

Instance Method Summary collapse

Instance Method Details

#overall(season) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/celly/standings.rb', line 7

def overall(season)
  end_point = "/standings?#{season}"
  uri = URI("#{BASE_URL}#{end_point}")
  response = Net::HTTP.get_response(uri)

  if response.code == '200'
    json_response = JSON.parse(response.body)
    
    {status: response.code, message: response.message, data: json_response["records"]}
  else
    {status: response.code, message: response.message}
  end
end