Class: DecisionReview::Configuration

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

Overview

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

Direct Known Subclasses

PdfValidation::Configuration

Instance Attribute Summary

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

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

Class Method Summary collapse

Instance Method Summary collapse

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

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

Class Method Details

.base_request_headersHash

Returns The basic headers required for any decision review API call.

Returns:

  • (Hash)

    The basic headers required for any decision review API call.



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

def self.base_request_headers
  super.merge('apiKey' => Settings.decision_review.api_key)
end

Instance Method Details

#base_pathString

Returns Base path for decision review URLs.

Returns:

  • (String)

    Base path for decision review URLs.



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

def base_path
  Settings.decision_review.url
end

#breakers_error_thresholdObject



61
62
63
# File 'lib/decision_review/configuration.rb', line 61

def breakers_error_threshold
  80 # breakers will be tripped if error rate reaches 80% over a two minute period.
end

#connectionFaraday::Connection

Creates the a connection with 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
52
# File 'lib/decision_review/configuration.rb', line 40

def connection
  @conn ||= Faraday.new(base_path, headers: base_request_headers, request: request_options) do |faraday|
    faraday.use      :breakers
    faraday.use      Faraday::Response::RaiseError

    faraday.request :multipart
    faraday.request :json

    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.



57
58
59
# File 'lib/decision_review/configuration.rb', line 57

def mock_enabled?
  Settings.decision_review.mock || false
end

#service_nameString

Returns Service name to use in breakers and metrics.

Returns:

  • (String)

    Service name to use in breakers and metrics.



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

def service_name
  'DecisionReview'
end