Class: Caseflow::Configuration

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

Overview

HTTP client configuration for the Service, sets the base path, a default timeout, and a service name for breakers and metrics.

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

#app_tokenString

Returns The auth token for the caseflow service.

Returns:

  • (String)

    The auth token for the caseflow service.



17
18
19
# File 'lib/caseflow/configuration.rb', line 17

def app_token
  Settings.caseflow.app_token
end

#base_pathString

Returns Base path for caseflow URLs.

Returns:

  • (String)

    Base path for caseflow URLs.



24
25
26
# File 'lib/caseflow/configuration.rb', line 24

def base_path
  Settings.caseflow.host
end

#connectionFaraday::Connection

Creates the a connection with middleware for mapping errors, parsing json, and adding breakers functionality.

Returns:

  • (Faraday::Connection)

    a Faraday connection instance.



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/caseflow/configuration.rb', line 40

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

    faraday.response :raise_custom_error, error_prefix: service_name
    faraday.response :caseflow_errors
    faraday.response :betamocks if mock_enabled?
    faraday.response :json
    faraday.adapter Faraday.default_adapter
  end
end

#mock_enabled?Boolean

Returns Should the service use mock data in lower environments.

Returns:

  • (Boolean)

    Should the service use mock data in lower environments.



56
57
58
# File 'lib/caseflow/configuration.rb', line 56

def mock_enabled?
  [true, 'true'].include?(Settings.caseflow.mock)
end

#service_nameString

Returns Service name to use in breakers and metrics.

Returns:

  • (String)

    Service name to use in breakers and metrics.



31
32
33
# File 'lib/caseflow/configuration.rb', line 31

def service_name
  'CaseflowStatus'
end