class Sports::Butler::SoccerApi::FootballDataOrg::Countries

Public Instance Methods

available_endpoint_methods() click to toggle source
# File lib/sports/butler/soccer_api/football_data_org/countries.rb, line 11
def available_endpoint_methods
  [:all, :by_name, :by_id]
end
by_id(id:, filters: {}) click to toggle source
# File lib/sports/butler/soccer_api/football_data_org/countries.rb, line 19
def by_id(id:, filters: {})
  api_with_id(id, filters)
end
by_name(name:, _filters: {}) click to toggle source
# File lib/sports/butler/soccer_api/football_data_org/countries.rb, line 23
def by_name(name:, _filters: {})
  api = all

  return api if api.parsed_response.is_a?(Hash) &&
    api.parsed_response.with_indifferent_access.dig('message')

  country = api.parsed_response['areas'].detect { |area| area['name'] == name }

  if country
    by_id(id: country['id'])
  else
    api.parsed_response = not_found_result(name)
    api
  end

end
path() click to toggle source
# File lib/sports/butler/soccer_api/football_data_org/countries.rb, line 15
def path
  :areas
end