Class: Football::Butler::FootballData::Areas
- Defined in:
- lib/football/butler/football_data/areas.rb
Constant Summary collapse
- PATH =
:areas
Constants inherited from Base
Class Method Summary collapse
-
.all(result:) ⇒ Object
AREAS v2/areas.
-
.by_id(id:) ⇒ Object
AREA v2/areas/id returns area object directly as a hash.
-
.by_name(name:, result:, filters:) ⇒ Object
ADDITIONAL v2/areas v2/areas/id returns area object directly as a hash.
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:) ⇒ Object
AREAS v2/areas
20 21 22 |
# File 'lib/football/butler/football_data/areas.rb', line 20 def all(result:) Api.get(path: PATH, result: result) end |
.by_id(id:) ⇒ Object
AREA v2/areas/id returns area object directly as a hash
13 14 15 16 |
# File 'lib/football/butler/football_data/areas.rb', line 13 def by_id(id:) path = "#{PATH}/#{id}" Api.get(path: path) end |
.by_name(name:, result:, filters:) ⇒ Object
ADDITIONAL v2/areas v2/areas/id returns area object directly as a hash
28 29 30 31 32 33 34 35 |
# File 'lib/football/butler/football_data/areas.rb', line 28 def by_name(name:, result:, filters:) areas = all(result: PATH) return areas if areas.is_a?(Hash) && areas.with_indifferent_access.dig('message') area = areas&.detect { |area| area['name'] == name } return not_found_result(name) unless area by_id(id: area['id']) end |