class Football::Butler::FootballData::Competitions

Constants

PATH

Public Class Methods

all(result:, filters: Configuration.tier_plan_filter) click to toggle source
COMPETITIONS

areas={AREAS} plan={PLAN}

v2/competitions

# File lib/football/butler/football_data/competitions.rb, line 24
def all(result:, filters: Configuration.tier_plan_filter)
  Api.get(path: PATH, result: result, filters: filters)
end
all_tier_plan_filter(result:, filters:) click to toggle source

v2/competitions

# File lib/football/butler/football_data/competitions.rb, line 29
def all_tier_plan_filter(result:, filters:)
  Api.get(path: PATH, result: result, filters: filters)
end
by_areas(ids:, result:, filters:) click to toggle source

v2/competitions?areas={id1, id2, …}

# File lib/football/butler/football_data/competitions.rb, line 40
def by_areas(ids:, result:, filters:)
  filters.merge!({ areas: ids.join(',') })
  Api.get(path: PATH, result: result, filters: filters)
end
by_id(id:) click to toggle source
COMPETITION

v2/competitions/{id} returns competition object directly as a hash

# File lib/football/butler/football_data/competitions.rb, line 13
def by_id(id:)
  path = "#{PATH}/#{id}"
  Api.get(path: path)
end
by_plan(plan:, result:, filters:) click to toggle source

v2/competitions?plan={plan}

# File lib/football/butler/football_data/competitions.rb, line 34
def by_plan(plan:, result:, filters:)
  filters.merge!({ plan: plan })
  Api.get(path: PATH, result: result, filters: filters)
end
current_match_day(id:) click to toggle source
ADDITIONAL

v2/competitions/{id}

# File lib/football/butler/football_data/competitions.rb, line 47
def current_match_day(id:)
  response = by_id(id:id)

  if response.is_a?(Hash) && response.dig('message')
    response
  else
    response['currentSeason']['currentMatchday']
  end
end
seasons(id:) click to toggle source

v2/competitions/{id}

# File lib/football/butler/football_data/competitions.rb, line 58
def seasons(id:)
  response = by_id(id:id)

  if response.is_a?(Hash) && response.dig('message')
    response
  else
    response['seasons']
  end
end