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

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:



34
35
36
# File 'lib/sports_odds_api/resources/leagues.rb', line 34

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:



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

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