class Footballdata::Metal

todo/check: put in Downloader namespace/class - why? why not?

or use Metal    - no "porcelain" downloaders / machinery

Constants

BASE_URL

Public Class Methods

competition_matches_url( code, year ) click to toggle source

just use matches_url - why? why not?

# File lib/webget-football/apis/download.rb, line 29
def self.competition_matches_url( code, year )  "#{BASE_URL}/competitions/#{code}/matches?season=#{year}"; end
competition_teams_url( code, year ) click to toggle source
# File lib/webget-football/apis/download.rb, line 30
def self.competition_teams_url( code, year )    "#{BASE_URL}/competitions/#{code}/teams?season=#{year}";   end
competitions_tier_one() click to toggle source
# File lib/webget-football/apis/download.rb, line 34
def self.competitions_tier_one
  get( competitions_url( 'TIER_ONE' ))
end
competitions_tier_three() click to toggle source
# File lib/webget-football/apis/download.rb, line 42
def self.competitions_tier_three
  get( competions_url( 'TIER_THREE' ))
end
competitions_tier_two() click to toggle source
# File lib/webget-football/apis/download.rb, line 38
def self.competitions_tier_two
  get( competions_url( 'TIER_TWO' ))
end
competitions_url( plan ) click to toggle source
# File lib/webget-football/apis/download.rb, line 26
def self.competitions_url( plan )  "#{BASE_URL}/competitions?plan=#{plan}"; end
get( url ) click to toggle source
def self.matches
  # note: Specified period must not exceed 10 days.
  ## try query (football) week by week - tuesday to monday!!
  ##  note: TIER_ONE does NOT include goals!!!
  code       = 'FL1'
  start_date = '2019-08-09'
  end_date   = '2019-08-16'
  get( "matches?competitions=#{code}&dateFrom=#{start_date}&dateTo=#{end_date}" )
end

end

# File lib/webget-football/apis/download.rb, line 70
def self.get( url )
  token = ENV['FOOTBALLDATA']
  ## note: because of public workflow log - do NOT output token
  ## puts token

  headers = {}
  headers['X-Auth-Token'] = token    if token
  headers['User-Agent']   = 'ruby'
  headers['Accept']       = '*/*'

  ## note: add format: 'json' for pretty printing json (before) save in cache
  response = Webget.call( url, headers: headers )

  ## for debugging print pretty printed json first 400 chars
  puts response.json.pretty_inspect[0..400]

  exit 1  if response.status.nok?   # e.g. HTTP status code != 200
end
matches( code, year ) click to toggle source
# File lib/webget-football/apis/download.rb, line 51
def self.matches( code, year )
  get( competition_matches_url( code, year ))
end
teams( code, year ) click to toggle source
# File lib/webget-football/apis/download.rb, line 47
def self.teams( code, year )
  get( competition_teams_url( code, year ))
end