Class: Football::Butler::FootballData::Matches

Inherits:
Base
  • Object
show all
Defined in:
lib/football/butler/football_data/matches.rb

Constant Summary collapse

PATH =
:matches
STATUS_SCHEDULED =
'SCHEDULED'
STATUS_FINISHED =
'FINISHED'

Constants inherited from Base

Base::MSG_INVALID_CONFIG

Class Method Summary collapse

Methods inherited from Base

api_class, api_switch, api_switch_method, api_switch_result, error_message, invalid_config_result, not_found_result, reached_limit?, this_class, unsupported_api_call, unsupported_api_endpoint

Class Method Details

.all(result:, filters:) ⇒ Object

MATCHES

competitions=competitionIds dateFrom=DATE dateTo=DATE status=STATUS

/v2/matches



28
29
30
# File 'lib/football/butler/football_data/matches.rb', line 28

def all(result:, filters:)
  Api.get(path: PATH, result: result, filters: filters)
end

.by_competition(id:, result:, filters:) ⇒ Object

by COMPETITION

dateFrom=DATE dateTo=DATE stage=STAGE status=STATUS matchday=MATCHDAY group=GROUP season=YEAR

v2/competitions/id/matches



43
44
45
46
# File 'lib/football/butler/football_data/matches.rb', line 43

def by_competition(id:, result:, filters:)
  path = "#{Competitions::PATH}/#{id}/#{PATH}"
  Api.get(path: path, filters: filters, result: result)
end

.by_competition_and_match_day(id:, match_day:, result:, filters:) ⇒ Object

v2/competitions/id/matches?matchday=match_day



56
57
58
59
60
# File 'lib/football/butler/football_data/matches.rb', line 56

def by_competition_and_match_day(id:, match_day:, result:, filters:)
  path = "#{Competitions::PATH}/#{id}/#{PATH}"
  filters.merge!({ matchday: match_day })
  Api.get(path: path, filters: filters, result: result)
end

.by_competition_and_year(id:, year:, result:, filters:) ⇒ Object

v2/competitions/id/matches?season=year



49
50
51
52
53
# File 'lib/football/butler/football_data/matches.rb', line 49

def by_competition_and_year(id:, year:, result:, filters:)
  path = "#{Competitions::PATH}/#{id}/#{PATH}"
  filters.merge!({ season: year })
  Api.get(path: path, filters: filters, result: result)
end

.by_id(id:) ⇒ Object

MATCH v2/matches/id returns [“head2head”, “match”]



15
16
17
18
# File 'lib/football/butler/football_data/matches.rb', line 15

def by_id(id:)
  path = "#{PATH}/#{id}"
  Api.get(path: path)
end

.by_player(id:, result:, filters:) ⇒ Object

PLAYER

dateFrom=DATE dateTo=DATE status=STATUS competitions=competitionIds limit=LIMIT

/v2/players/id/matches



102
103
104
105
# File 'lib/football/butler/football_data/matches.rb', line 102

def by_player(id:, result:, filters:)
  path = "#{Players::PATH}/#{id}/#{PATH}"
  Api.get(path: path, result: result, filters: filters)
end

.by_team(id:, result:, filters:) ⇒ Object

by TEAM

dateFrom=DATE dateTo=DATE status=STATUS venue=VENUE limit=LIMIT

v2/teams/id/matches



71
72
73
74
# File 'lib/football/butler/football_data/matches.rb', line 71

def by_team(id:, result:, filters:)
  path = "#{Teams::PATH}/#{id}/#{PATH}"
  Api.get(path: path, result: result, filters: filters)
end

.by_team_and_status(id:, status:, result:, filters:) ⇒ Object

v2/teams/id/matches?status=status



77
78
79
80
81
# File 'lib/football/butler/football_data/matches.rb', line 77

def by_team_and_status(id:, status:, result:, filters:)
  path = "#{Teams::PATH}/#{id}/#{PATH}"
  filters.merge!({ status: status })
  Api.get(path: path, result: result, filters: filters)
end

.by_team_finished(id:, result:, filters:) ⇒ Object

v2/teams/team/matches?status=FINISHED



84
85
86
# File 'lib/football/butler/football_data/matches.rb', line 84

def by_team_finished(id:, result:, filters:)
  by_team_and_status(id: id, status: STATUS_FINISHED, result: result, filters: filters)
end

.by_team_scheduled(id:, result:, filters:) ⇒ Object

v2/teams/team/matches?status=SCHEDULED



89
90
91
# File 'lib/football/butler/football_data/matches.rb', line 89

def by_team_scheduled(id:, result:, filters:)
  by_team_and_status(id: id, status: STATUS_SCHEDULED, result: result, filters: filters)
end