Class: Sports::Butler::SoccerApi::ApifootballCom::Matches

Inherits:
Matches show all
Defined in:
lib/sports/butler/soccer_api/apifootball_com/matches.rb

Instance Attribute Summary

Attributes inherited from Endpoints

#api, #api_name, #sport

Instance Method Summary collapse

Methods inherited from Base

#error_message, #method_missing, #not_found_result

Methods inherited from Endpoints

#error_missing_endpoint_method, #filters_by_competition, #filters_by_competition_and_year, #filters_by_match, #filters_by_player, #filters_by_team, #filters_search_by_name, #initialize

Methods included from Sports::Butler::Shared::ApiComs

#cups, #leagues

Methods included from Sports::Butler::Shared::AllSports

#all, #by_coach, #by_code, #by_competition, #by_competition_and_range, #by_competition_and_season, #by_competition_and_team_and_season, #by_country, #by_country_name, #by_id, #by_id_and_season, #by_match, #by_name, #by_player, #by_season, #by_team, #by_team_and_range, #by_team_and_season, #by_teams, #search_by_name

Constructor Details

This class inherits a constructor from Sports::Butler::Endpoints

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Sports::Butler::SoccerApi::Base

Instance Method Details

#available_endpoint_methodsObject



8
9
10
# File 'lib/sports/butler/soccer_api/apifootball_com/matches.rb', line 8

def available_endpoint_methods
  [:by_id, :by_competition_and_year, :by_team_and_range, :by_competition_and_range]
end

#build_path(action) ⇒ Object



12
13
14
# File 'lib/sports/butler/soccer_api/apifootball_com/matches.rb', line 12

def build_path(action)
  "action=#{action}"
end

#by_competition_and_year(competition_id:, year:, filters: {}) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/sports/butler/soccer_api/apifootball_com/matches.rb', line 20

def by_competition_and_year(competition_id:, year:, filters: {})
  from  = "#{year}-01-01"
  to    = "#{year}-12-31"
  filters.merge!({ league_id: competition_id, from: from, to: to })
  api.get(path: build_path(path), filters: filters)
  api
end

#filters_by_competition_and_range(competition_id, from, to) ⇒ Object



32
33
34
# File 'lib/sports/butler/soccer_api/apifootball_com/matches.rb', line 32

def filters_by_competition_and_range(competition_id, from, to)
  { league_id: competition_id, from: from, to: to }
end

#filters_by_id(id) ⇒ Object



28
29
30
# File 'lib/sports/butler/soccer_api/apifootball_com/matches.rb', line 28

def filters_by_id(id)
  { match_id: id }
end

#pathObject



16
17
18
# File 'lib/sports/butler/soccer_api/apifootball_com/matches.rb', line 16

def path
  :get_events
end