Class: MLB::Transactions

Inherits:
Shale::Mapper
  • Object
show all
Defined in:
lib/mlb/transactions.rb

Overview

Provides methods for fetching MLB transactions from the API

Class Method Summary collapse

Class Method Details

.between(start_date: Date.today, end_date: start_date) ⇒ Array<Transaction>

Retrieves transactions between two dates

Examples:

MLB::Transactions.between(start_date: Date.new(2024, 1, 1), end_date: Date.new(2024, 1, 31))

Parameters:

  • start_date (Date) (defaults to: Date.today)

    the start date

  • end_date (Date) (defaults to: start_date)

    the end date

Returns:



17
18
19
20
21
# File 'lib/mlb/transactions.rb', line 17

def self.between(start_date: Date.today, end_date: start_date)
  params = {startDate: start_date, endDate: end_date}
  response = CLIENT.get("transactions?#{Utils.build_query(params)}")
  from_json(response).transactions
end