Module: MLBStatsAPI::Schedules

Included in:
Client
Defined in:
lib/mlb_stats_api/schedules.rb

Constant Summary collapse

SCHEDULE_TYPES =
{
  default: '/schedule',
  postseason: '/schedule/postseason',
  tied: '/schedule/games/tied',
  postseason_series: '/schedule/postseason/series',
  tune_in: '/schedule/postseason/tuneIn'
}.freeze

Instance Method Summary collapse

Instance Method Details

#schedule(type = :default, options = {}) ⇒ Object

Raises:

  • (ArgumentError)


13
14
15
16
17
18
19
20
21
22
# File 'lib/mlb_stats_api/schedules.rb', line 13

def schedule(type = :default, options = {})
  if type.is_a?(Hash) && options.empty?
    options = type
    type = :default
  end

  raise ArgumentError, 'invalid schedule type' unless SCHEDULE_TYPES[type]

  get SCHEDULE_TYPES[type], { sportId: 1 }.merge(options)
end