Class: SportsOddsAPI::Resources::Leagues

Inherits:
Object
  • Object
show all
Defined in:
lib/sports_odds_api/resources/leagues.rb,
sig/sports_odds_api/resources/leagues.rbs

Overview

Get League-related data

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Leagues

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Leagues.

Parameters:



36
37
38
# File 'lib/sports_odds_api/resources/leagues.rb', line 36

def initialize(client:)
  @client = client
end

Instance Method Details

#get(league_id: nil, sport_id: nil, request_options: {}) ⇒ Array<SportsOddsAPI::Models::League>

Get a list of Leagues

Parameters:

  • league_id (String)

    The league to get data for

  • sport_id (String)

    The sport to get leagues for

  • request_options (SportsOddsAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sports_odds_api/resources/leagues.rb', line 20

def get(params = {})
  parsed, options = SportsOddsAPI::LeagueGetParams.dump_request(params)
  query = SportsOddsAPI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "leagues/",
    query: query.transform_keys(league_id: "leagueID", sport_id: "sportID"),
    unwrap: :data,
    model: SportsOddsAPI::Internal::Type::ArrayOf[SportsOddsAPI::League],
    options: options
  )
end