Module: FootballData

Extended by:
Configuration
Defined in:
lib/football__data.rb,
lib/football__data/version.rb,
lib/football__data/configuration.rb

Defined Under Namespace

Modules: Configuration

Constant Summary

VERSION =
"0.1.0"

Constants included from Configuration

Configuration::API_ENDPOINT, Configuration::DEFAULT_API_KEY, Configuration::DEFAULT_API_VERSON, Configuration::DEFAULT_RESPONSE_CONTROL

Instance Attribute Summary

Attributes included from Configuration

#api_key, #api_version, #response_control

Class Method Summary collapse

Methods included from Configuration

configure, reset!

Class Method Details

.fetch(resource, subresource = nil, params = {}) ⇒ Object

main method of FootballData, fetch info of football matches and players see 'api.football-data.org/documentation' for details

Parameters:

  • resource (Symbol, String)

    one of :soccerseasons, :teams, :fixtures

  • subresource (Symbol, String) (defaults to: nil)

    :soccerseasons => one of :fixtures, :teams, :leagueTable :teams => one of :fixtures, :players

  • params (Hash) (defaults to: {})

    the filter parameters, :id is also pass by params



19
20
21
22
23
24
25
26
# File 'lib/football__data.rb', line 19

def fetch(resource, subresource = nil, params = {})
    id, filter = parse_params(params)
    path = "/#{@api_version}/#{resource}"
    path += "/#{id}/#{subresource}" if id
    path += "?#{filter}" if filter
    response = get(path)
    JSON.parse(response.body)
end