Class: Football::Butler::Apifootball::Events

Inherits:
BaseApifootball show all
Defined in:
lib/football/butler/apifootball/events.rb

Constant Summary collapse

PATH =
:get_events

Constants inherited from Base

Base::MSG_INVALID_CONFIG

Class Method Summary collapse

Methods inherited from BaseApifootball

build_path

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

EVENTS

timezone Default timezone: Europe/Berlin.

With this filter you can set the timezone where you want to receive the data.
Timezone is in TZ format (exemple: America/New_York). (Optional)

from Start date (yyyy-mm-dd) to Stop date (yyyy-mm-dd) country_id Country ID if set only leagues from specific country will be returned (Optional) league_id League ID if set events from specific league will be returned (Optional) match_id Match ID if set only details from specific match will be returned (Optional) team_id Team ID if set only details from specific team will be returned (Optional)

action=get_events&…<AT LEAST ONE PARAMETER IS REQUIRED!> “error”: 201, “message”: “Required parameters missing”



32
33
34
# File 'lib/football/butler/apifootball/events.rb', line 32

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

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

by COMPETITION action=get_events?league_id=id



38
39
40
41
# File 'lib/football/butler/apifootball/events.rb', line 38

def by_competition(id:, result:, filters:)
  filters.merge!({ league_id: id })
  Api.get(path: build_path(PATH), filters: filters, result: result)
end

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

action=get_events?league_id=id&from=year-01-01&year-12-31



44
45
46
47
48
49
# File 'lib/football/butler/apifootball/events.rb', line 44

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

.by_id(id:) ⇒ Object

EVENT action=get_events?match_id=id



13
14
15
16
# File 'lib/football/butler/apifootball/events.rb', line 13

def by_id(id:)
  filters = { match_id: id }
  Api.get(path: build_path(PATH), result: :parsed_response, filters: filters)
end

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

by TEAM action=get_events?team_id=id



53
54
55
56
# File 'lib/football/butler/apifootball/events.rb', line 53

def by_team(id:, result:, filters:)
  filters.merge!({ team_id: id })
  Api.get(path: build_path(PATH), result: result, filters: filters)
end