Class: UserEligibility::Configuration

Inherits:
Common::Client::Configuration::REST show all
Defined in:
lib/medical_records/user_eligibility/configuration.rb

Overview

HTTP client configuration for Client

Instance Attribute Summary

Attributes inherited from Common::Client::Configuration::Base

#base_request_headers, #open_timeout, #read_timeout, #request_types, #user_agent

Instance Method Summary collapse

Methods inherited from Common::Client::Configuration::Base

#breakers_error_threshold, #breakers_exception_handler, #breakers_matcher, #breakers_service, #create_new_breakers_service, #current_module, #request_options, #service_exception

Instance Method Details

#base_pathString

Returns Base path for dependent URLs.

Returns:

  • (String)

    Base path for dependent URLs



21
22
23
# File 'lib/medical_records/user_eligibility/configuration.rb', line 21

def base_path
  "#{Settings.mhv.medical_records.host}/mhvapi/v1/usermgmt/usereligibility/"
end

#connectionFaraday::Connection

Creates a connection

Returns:

  • (Faraday::Connection)

    a Faraday connection instance



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/medical_records/user_eligibility/configuration.rb', line 47

def connection
  Faraday.new(base_path, headers: base_request_headers, request: request_options) do |conn|
    conn.use :breakers
    conn.request :multipart_request
    conn.request :multipart
    conn.request :json

    # Uncomment this if you want curl command equivalent or response output to log
    # conn.request(:curl, ::Logger.new(STDOUT), :warn) unless Rails.env.production?
    # conn.response(:logger, ::Logger.new(STDOUT), bodies: true) unless Rails.env.production?

    conn.response :raise_custom_error, error_prefix: service_name
    conn.response :mhv_errors
    conn.response :mhv_xml_html_errors
    conn.response :json_parser
    conn.adapter Faraday.default_adapter
  end
end

#service_nameString

Returns Service name to use in breakers and metrics.

Returns:

  • (String)

    Service name to use in breakers and metrics



38
39
40
# File 'lib/medical_records/user_eligibility/configuration.rb', line 38

def service_name
  'UserEligibility'
end

#x_headersHash

Returns Headers with x-api-key and RX appToken header values for dependent URLs.

Returns:

  • (Hash)

    Headers with x-api-key and RX appToken header values for dependent URLs



28
29
30
31
32
33
# File 'lib/medical_records/user_eligibility/configuration.rb', line 28

def x_headers
  base_request_headers.merge({
                               'x-api-key': Settings.mhv.medical_records.mhv_x_api_key,
                               appToken: Settings.mhv.rx.app_token
                             })
end