Class: BenefitsIntakeService::Configuration

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

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

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



8
9
10
11
12
# File 'lib/benefits_intake_service/configuration.rb', line 8

def initialize
  super
  Settings.benefits_intake_service.api_key ||= Settings.form526_backup.api_key
  Settings.benefits_intake_service.url ||= Settings.form526_backup.url
end

Class Method Details

.base_request_headersHash

Returns The basic headers required for any Lighthouse API call.

Returns:

  • (Hash)

    The basic headers required for any Lighthouse API call



33
34
35
# File 'lib/benefits_intake_service/configuration.rb', line 33

def self.base_request_headers
  super.merge('apikey' => Settings.benefits_intake_service.api_key)
end

Instance Method Details

#base_pathString

Returns Base path.

Returns:

  • (String)

    Base path



19
20
21
# File 'lib/benefits_intake_service/configuration.rb', line 19

def base_path
  Settings.benefits_intake_service.url
end

#breakers_error_thresholdObject



63
64
65
# File 'lib/benefits_intake_service/configuration.rb', line 63

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

#connectionFaraday::Connection

Creates a connection with json parsing and breaker functionality.

Returns:

  • (Faraday::Connection)

    a Faraday connection instance.



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/benefits_intake_service/configuration.rb', line 42

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.



59
60
61
# File 'lib/benefits_intake_service/configuration.rb', line 59

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

#service_nameString

Returns Service name to use in breakers and metrics.

Returns:

  • (String)

    Service name to use in breakers and metrics.



26
27
28
# File 'lib/benefits_intake_service/configuration.rb', line 26

def service_name
  'BenefitsIntakeService'
end