Class: SubscriptionsTestKit::SubscriptionReadEndpoint

Inherits:
Inferno::DSL::SuiteEndpoint
  • Object
show all
Includes:
SubscriptionsTestKit::SubscriptionsR5BackportR4Client::SubscriptionSimulationUtils
Defined in:
lib/subscriptions_test_kit/endpoints/subscription_read_endpoint.rb

Constant Summary

Constants included from SubscriptionsTestKit::SubscriptionsR5BackportR4Client::SubscriptionSimulationUtils

SubscriptionsTestKit::SubscriptionsR5BackportR4Client::SubscriptionSimulationUtils::ALLOWED_MIME_TYPES, SubscriptionsTestKit::SubscriptionsR5BackportR4Client::SubscriptionSimulationUtils::DEFAULT_MIME_TYPE

Instance Method Summary collapse

Methods included from SubscriptionsTestKit::SubscriptionsR5BackportR4Client::SubscriptionSimulationUtils

#actual_mime_type, #client_access_token_input, #derive_event_notification, #derive_handshake_notification, #derive_status_bundle, #determine_event_count, #determine_subscription_status_code, #find_subscription, #notification_bundle_input, #operation_outcome

Instance Method Details

#make_responseObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/subscriptions_test_kit/endpoints/subscription_read_endpoint.rb', line 12

def make_response
  response.format = :json
  subscription_id = request.params[:id]

  subscription = find_subscription(test_run.test_session_id)

  if subscription.present? && subscription.id == subscription_id
    status_code = determine_subscription_status_code(subscription_id)
    response.body = subscription.source_hash.merge('status' => status_code).to_json
  else
    response.status = 404
    response.body = operation_outcome('error', 'not-found',
                                      "No subscription exists with ID #{subscription_id}").to_json
  end
end

#tagsObject



28
29
30
# File 'lib/subscriptions_test_kit/endpoints/subscription_read_endpoint.rb', line 28

def tags
  [SUBSCRIPTION_READ_TAG]
end

#test_run_identifierObject



8
9
10
# File 'lib/subscriptions_test_kit/endpoints/subscription_read_endpoint.rb', line 8

def test_run_identifier
  request.headers['authorization']&.delete_prefix('Bearer ')
end