Class: MLB::PeopleChanges

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

Overview

Provides methods for fetching people changes from the API

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#peopleArray<Player>

Returns the changed people

Examples:

people_changes.people #=> [#<MLB::Player>, ...]

Returns:

  • (Array<Player>)

    the changed people



14
# File 'lib/mlb/people_changes.rb', line 14

attribute :people, Player, collection: true

Class Method Details

.since(date:) ⇒ Array<Player>

Retrieves people changes since a date

Examples:

Get people changes since a date

MLB::PeopleChanges.since(date: Date.new(2024, 6, 1))

Parameters:

  • date (Date)

    the date to check changes from

Returns:

  • (Array<Player>)

    the changed people



27
28
29
30
31
32
# File 'lib/mlb/people_changes.rb', line 27

def self.since(date:)
  params = {updatedSince: date.to_s}
  query_string = URI.encode_www_form(params)
  response = CLIENT.get("people/changes?#{query_string}")
  from_json(response).people
end