class Sports::Butler::SoccerApi::FootballDataOrg::Lineups

Public Instance Methods

by_match(match_id:, filters: {}) click to toggle source
# File lib/sports/butler/soccer_api/football_data_org/lineups.rb, line 9
def by_match(match_id:, filters: {})
  api.get(path: "#{path}/#{match_id}", filters: filters)
  response = api.response.parsed_response

  if response.is_a?(Hash) && response.with_indifferent_access.dig(:match) &&
    response['match'].with_indifferent_access.dig(:homeTeam) &&
    response['match'].with_indifferent_access.dig(:awayTeam)

    lineups = {}
    lineups['homeTeam'] = response['match']['homeTeam']
    lineups['awayTeam'] = response['match']['awayTeam']

    api.parsed_response = lineups
  else
    api.parsed_response = response
  end

  api
end