Class: Jumbotron::Deserializers::Clients::Espn::Teams::Get

Inherits:
Object
  • Object
show all
Defined in:
app/deserializers/jumbotron/deserializers/clients/espn/teams/get.rb

Class Method Summary collapse

Class Method Details

.call(payload) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'app/deserializers/jumbotron/deserializers/clients/espn/teams/get.rb', line 9

def self.call(payload)
  Support.ensure_hash!(payload, label: "teams")

  teams_raw = extract_team_entries(payload)
  teams_raw.each_with_index.map do |entry, index|
    team_payload = entry.is_a?(Hash) ? (entry["team"] || entry) : entry
    Team.call(team_payload)
  rescue CommandTower::Clients::Errors::DeserializationError => e
    raise CommandTower::Deserializers::Clients::Errors.prefix(e, "teams[#{index}]")
  end
end