Class: DaVinciCRDTestKit::HookRequestEndpoint
- Inherits:
-
Inferno::DSL::SuiteEndpoint
- Object
- Inferno::DSL::SuiteEndpoint
- DaVinciCRDTestKit::HookRequestEndpoint
show all
- Includes:
- MockServiceResponse
- Defined in:
- lib/davinci_crd_test_kit/routes/hook_request_endpoint.rb
Instance Method Summary
collapse
#add_basic_cards, #add_coverage_cards, #add_coverage_cards?, #add_coverage_extension, #add_order_hook_cards, #context, #coverage_information_required?, #coverage_information_required_hooks, #create_alternate_request_card, #create_card_response, #create_cards_and_system_actions, #create_companions_prerequisites_card, #create_coverage_extension_system_actions, #create_coverage_resource, #create_form_completion_card, #create_or_update_coverage, #create_system_actions, #create_warning_messages, #current_time, #format_missing_response_types, #get_context_resource, #get_missing_response_types, #get_patient_coverage, #hook_response, #load_json_file, #make_resource_request, #missing_response_type_filter, #request_body, #resource_to_update_field_name, #resource_type_to_update, #update_service_request, #update_specific_hook_card_info
Instance Method Details
#custom_response ⇒ Object
14
15
16
17
18
19
|
# File 'lib/davinci_crd_test_kit/routes/hook_request_endpoint.rb', line 14
def custom_response
@custom_response ||=
JSON.parse(result.input_json)
.find { |input| input['name'].include?('custom_response') }
&.dig('value')
end
|
#hook_name ⇒ Object
25
26
27
|
# File 'lib/davinci_crd_test_kit/routes/hook_request_endpoint.rb', line 25
def hook_name
@hook_name ||= request.params[:hook]
end
|
#iss ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'lib/davinci_crd_test_kit/routes/hook_request_endpoint.rb', line 29
def iss
@iss ||=
begin
payload, = JWT.decode(token, nil, false)
payload['iss']
rescue JWT::DecodeError
nil
end
end
|
#make_response ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'lib/davinci_crd_test_kit/routes/hook_request_endpoint.rb', line 43
def make_response
case hook_name
when 'appointment-book', 'encounter-start', 'encounter-discharge', 'order-select', 'order-sign', 'order-dispatch'
hook_response
else
response.status = 400
response.body = 'Invalid Request: Request did not contain a valid hook in the `hook` field.'
end
end
|
#name ⇒ Object
73
74
75
|
# File 'lib/davinci_crd_test_kit/routes/hook_request_endpoint.rb', line 73
def name
hook_name.gsub('-', '_')
end
|
#selected_response_types ⇒ Object
7
8
9
10
11
12
|
# File 'lib/davinci_crd_test_kit/routes/hook_request_endpoint.rb', line 7
def selected_response_types
@selected_response_types ||=
JSON.parse(result.input_json)
.find { |input| input['name'].include?('selected_response_types') }
&.dig('value')
end
|
#test_run_identifier ⇒ Object
21
22
23
|
# File 'lib/davinci_crd_test_kit/routes/hook_request_endpoint.rb', line 21
def test_run_identifier
"#{hook_name} #{iss}"
end
|
#token ⇒ Object
39
40
41
|
# File 'lib/davinci_crd_test_kit/routes/hook_request_endpoint.rb', line 39
def token
@token ||= request.['authorization']&.delete_prefix('Bearer ')
end
|