Class: SportsOddsAPI::Resources::Players

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

Overview

Get Player-related data

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Players

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 Players.

Parameters:



45
46
47
# File 'lib/sports_odds_api/resources/players.rb', line 45

def initialize(client:)
  @client = client
end

Instance Method Details

#get(cursor: nil, event_id: nil, limit: nil, player_id: nil, team_id: nil, request_options: {}) ⇒ SportsOddsAPI::Internal::NextCursorPage<SportsOddsAPI::Models::Player>

Some parameter documentations has been truncated, see Models::PlayerGetParams for more details.

Get a list of Players for a specific Team or Event

Parameters:

  • cursor (String)

    The cursor for the request. Used to get the next group of Players. This is an op

  • event_id (String)

    EventID to get Players data for

  • limit (Float)

    The maximum number of Players to return

  • player_id (String)

    PlayerID to get data for

  • team_id (String)

    TeamID to get Players data for

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

Returns:

See Also:



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/sports_odds_api/resources/players.rb', line 29

def get(params = {})
  parsed, options = SportsOddsAPI::PlayerGetParams.dump_request(params)
  query = SportsOddsAPI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "players/",
    query: query.transform_keys(event_id: "eventID", player_id: "playerID", team_id: "teamID"),
    page: SportsOddsAPI::Internal::NextCursorPage,
    model: SportsOddsAPI::Player,
    options: options
  )
end