Class: MLB::Roster
- Inherits:
-
Shale::Mapper
- Object
- Shale::Mapper
- MLB::Roster
- Defined in:
- lib/mlb/roster.rb
Overview
Provides methods for fetching team rosters from the API
Class Method Summary collapse
-
.find(team:, season: nil, sport: Utils::DEFAULT_SPORT_ID) ⇒ Array<RosterEntry>
Finds a team’s roster for a given season and sport.
Class Method Details
.find(team:, season: nil, sport: Utils::DEFAULT_SPORT_ID) ⇒ Array<RosterEntry>
Finds a team’s roster for a given season and sport
18 19 20 21 22 23 24 |
# File 'lib/mlb/roster.rb', line 18 def self.find(team:, season: nil, sport: Utils::DEFAULT_SPORT_ID) season ||= Utils.current_season team_id = Utils.extract_id(team) params = {season:, sportId: Utils.extract_id(sport)} response = CLIENT.get("teams/#{team_id}/roster?#{Utils.build_query(params)}") from_json(response).roster end |