Class: MLB::Transaction

Inherits:
Struct
  • Object
show all
Defined in:
lib/mlb/transaction.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#conditional_swObject

Returns the value of attribute conditional_sw

Returns:

  • (Object)

    the current value of conditional_sw



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def conditional_sw
  @conditional_sw
end

#effective_dateObject

Returns the value of attribute effective_date

Returns:

  • (Object)

    the current value of effective_date



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def effective_date
  @effective_date
end

#final_assetObject

Returns the value of attribute final_asset

Returns:

  • (Object)

    the current value of final_asset



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def final_asset
  @final_asset
end

#final_asset_typeObject

Returns the value of attribute final_asset_type

Returns:

  • (Object)

    the current value of final_asset_type



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def final_asset_type
  @final_asset_type
end

#from_teamObject

Returns the value of attribute from_team

Returns:

  • (Object)

    the current value of from_team



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def from_team
  @from_team
end

#from_team_idObject

Returns the value of attribute from_team_id

Returns:

  • (Object)

    the current value of from_team_id



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def from_team_id
  @from_team_id
end

#name_display_first_lastObject

Returns the value of attribute name_display_first_last

Returns:

  • (Object)

    the current value of name_display_first_last



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def name_display_first_last
  @name_display_first_last
end

#name_display_last_firstObject

Returns the value of attribute name_display_last_first

Returns:

  • (Object)

    the current value of name_display_last_first



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def name_display_last_first
  @name_display_last_first
end

#name_sortObject

Returns the value of attribute name_sort

Returns:

  • (Object)

    the current value of name_sort



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def name_sort
  @name_sort
end

#noteObject

Returns the value of attribute note

Returns:

  • (Object)

    the current value of note



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def note
  @note
end

#orig_assetObject

Returns the value of attribute orig_asset

Returns:

  • (Object)

    the current value of orig_asset



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def orig_asset
  @orig_asset
end

#orig_asset_typeObject

Returns the value of attribute orig_asset_type

Returns:

  • (Object)

    the current value of orig_asset_type



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def orig_asset_type
  @orig_asset_type
end

#playerObject

Returns the value of attribute player

Returns:

  • (Object)

    the current value of player



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def player
  @player
end

#player_idObject

Returns the value of attribute player_id

Returns:

  • (Object)

    the current value of player_id



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def player_id
  @player_id
end

#resolution_cdObject

Returns the value of attribute resolution_cd

Returns:

  • (Object)

    the current value of resolution_cd



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def resolution_cd
  @resolution_cd
end

#resolution_dateObject

Returns the value of attribute resolution_date

Returns:

  • (Object)

    the current value of resolution_date



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def resolution_date
  @resolution_date
end

#teamObject

Returns the value of attribute team

Returns:

  • (Object)

    the current value of team



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def team
  @team
end

#team_idObject

Returns the value of attribute team_id

Returns:

  • (Object)

    the current value of team_id



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def team_id
  @team_id
end

#trans_dateObject

Returns the value of attribute trans_date

Returns:

  • (Object)

    the current value of trans_date



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def trans_date
  @trans_date
end

#trans_date_cdObject

Returns the value of attribute trans_date_cd

Returns:

  • (Object)

    the current value of trans_date_cd



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def trans_date_cd
  @trans_date_cd
end

#transaction_idObject

Returns the value of attribute transaction_id

Returns:

  • (Object)

    the current value of transaction_id



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def transaction_id
  @transaction_id
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def type
  @type
end

#type_cdObject

Returns the value of attribute type_cd

Returns:

  • (Object)

    the current value of type_cd



5
6
7
# File 'lib/mlb/transaction.rb', line 5

def type_cd
  @type_cd
end

Class Method Details

.all(start_date: Date.today, end_date: Date.today) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/mlb/transaction.rb', line 10

def self.all(start_date: Date.today, end_date: Date.today)
  sport_code = "'mlb'"
  start_date = Date.parse(start_date.to_s).strftime("%Y%m%d")
  end_date = Date.parse(end_date.to_s).strftime("%Y%m%d")
  params = {sport_code:, start_date:, end_date:}
  query_string = URI.encode_www_form(params)
  response = CLIENT.get("named.transaction_all.bam?#{query_string}")
  transactions = response.fetch(:transaction_all, {}).fetch(:queryResults, {}).fetch(:row, [])
  transactions.collect { |transaction| Transaction.new(**transaction) }
end