Class: Sports::Butler::SoccerApi::FootballDataOrg::Matches

Inherits:
Matches show all
Includes:
Base
Defined in:
lib/sports/butler/soccer_api/football_data_org/matches.rb

Constant Summary collapse

STATUS_FINISHED =
'FINISHED'
STATUS_SCHEDULED =
'SCHEDULED'

Instance Attribute Summary

Attributes inherited from Endpoints

#api, #api_name, #sport

Instance Method Summary collapse

Methods included from Base

#api_with_id, #path_with_id

Methods inherited from Matches

#path

Methods inherited from Base

#error_message, #method_missing, #not_found_result

Methods inherited from Endpoints

#build_path, #error_missing_endpoint_method, #filters_by_competition, #filters_by_competition_and_year, #filters_by_id, #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_and_range, #by_competition_and_season, #by_competition_and_team_and_season, #by_country, #by_country_name, #by_id_and_season, #by_match, #by_name, #by_player, #by_season, #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



14
15
16
17
18
19
# File 'lib/sports/butler/soccer_api/football_data_org/matches.rb', line 14

def available_endpoint_methods
  [
    :by_id, :all, :by_competition, :by_competition_and_year, :by_team, :by_team_and_status,
    :by_team_finished, :by_team_scheduled
  ]
end

#by_competition(competition_id:, filters: {}) ⇒ Object



25
26
27
28
# File 'lib/sports/butler/soccer_api/football_data_org/matches.rb', line 25

def by_competition(competition_id:, filters: {})
  api.get(path: "competitions/#{competition_id}/#{path}", filters: filters)
  api
end

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



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

def by_competition_and_year(competition_id:, year:, filters: {})
  filters.merge!({ season: year })
  api.get(path: "competitions/#{competition_id}/#{path}", filters: filters)
  api
end

#by_id(id:, filters: {}) ⇒ Object



21
22
23
# File 'lib/sports/butler/soccer_api/football_data_org/matches.rb', line 21

def by_id(id:, filters: {})
  api_with_id(id, filters)
end

#by_team(team_id:, filters: {}) ⇒ Object



36
37
38
39
# File 'lib/sports/butler/soccer_api/football_data_org/matches.rb', line 36

def by_team(team_id:, filters: {})
  api.get(path: "teams/#{team_id}/#{path}", filters: filters)
  api
end

#by_team_and_status(team_id:, status:, filters: {}) ⇒ Object



41
42
43
44
45
# File 'lib/sports/butler/soccer_api/football_data_org/matches.rb', line 41

def by_team_and_status(team_id:, status:, filters: {})
  filters.merge!({ status: status })
  api.get(path: "teams/#{team_id}/#{path}", filters: filters)
  api
end

#by_team_finished(team_id:, filters: {}) ⇒ Object



47
48
49
# File 'lib/sports/butler/soccer_api/football_data_org/matches.rb', line 47

def by_team_finished(team_id:, filters: {})
  by_team_and_status(team_id: team_id, status: STATUS_FINISHED, filters: filters)
end

#by_team_scheduled(team_id:, filters: {}) ⇒ Object



51
52
53
# File 'lib/sports/butler/soccer_api/football_data_org/matches.rb', line 51

def by_team_scheduled(team_id:, filters: {})
  by_team_and_status(team_id: team_id, status: STATUS_SCHEDULED, filters: filters)
end