Class: Jumbotron::Workflows::ReadCurrentLinesWorkflow

Inherits:
CommandTower::Workflows::ApplicationWorkflow
  • Object
show all
Includes:
PublicRead
Defined in:
app/workflows/jumbotron/workflows/read_current_lines_workflow.rb

Instance Method Summary collapse

Methods included from PublicRead

#map_deserializer_failure, #map_service_failure

Instance Method Details

#call(**kwargs) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/workflows/jumbotron/workflows/read_current_lines_workflow.rb', line 10

def call(**kwargs)
  deserialized = Deserializers::Public::GameIds.call(kwargs)
  return map_deserializer_failure(deserialized) unless deserialized.success?

  loaded = Services::Public::LoadGamesByIds.call(game_ids: deserialized.input.game_ids)
  return map_service_failure(loaded) unless loaded.success?

  resolved = Services::Public::ResolveCurrentLinesForGames.call(games: loaded.data[:games])
  return map_service_failure(resolved) unless resolved.success?

  mapped = Services::Public::MapPublicCurrentLines.call(current_lines: resolved.data[:current_lines])
  return map_service_failure(mapped) unless mapped.success?

  success(payload: { current_lines: mapped.data[:public_current_lines] }, http_status: :ok)
end