Class: Overseer::TestingControl::Rails::StatesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/overseer/testing_control/rails/states_controller.rb

Instance Method Summary collapse

Instance Method Details

#create ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/overseer/testing_control/rails/states_controller.rb', line 9

def create
  document = request_document(:state_request)
  data = document.fetch('data')
  id, version = capability_reference(data)
  state = find_state(id, version)
  input = data.fetch('input')
  validate_capability_input!(state.input_schema, input, label: "state #{id}@#{version} input")
  idempotency_key = validated_idempotency_key(state)
  result = execute_state(state, input, idempotency_key)
  render_data(
    :state_response,
    {
      'capability' => { 'id' => id, 'version' => version },
      'identifiers' => result.fetch('identifiers'),
      'output' => result.fetch('output')
    }
  )
end