Class: DecisionReview::PdfValidation::Configuration

Inherits:
Configuration show all
Defined in:
lib/decision_review/utilities/pdf_validation/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 Configuration

#breakers_error_threshold, #mock_enabled?

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

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.

[View source] [View on GitHub]

23
24
25
26
27
28
29
30
31
# File 'lib/decision_review/utilities/pdf_validation/configuration.rb', line 23

def self.base_request_headers
  # Can use regular Decision Reviews API key in lower environments
  return super unless Rails.env.production?

  # Since we're using the `uploads/validate_document` endpoint under Benefits Intake API,
  # we need to use their API key. This is pulled from BenefitsIntakeService::Configuration
  api_key = Settings.benefits_intake_service.api_key || Settings.form526_backup.api_key
  super.merge('apiKey' => api_key)
end

Instance Method Details

#base_pathString

Returns Base path for PDF validation URL.

Returns:

  • (String)

    Base path for PDF validation URL.

[View source] [View on GitHub]

9
10
11
# File 'lib/decision_review/utilities/pdf_validation/configuration.rb', line 9

def base_path
  Settings.decision_review.pdf_validation.url
end

#connectionFaraday::Connection

Creates the a connection with parsing json and adding breakers functionality.

Returns:

  • (Faraday::Connection)

    a Faraday connection instance.

[View source] [View on GitHub]

38
39
40
41
42
43
44
45
46
47
# File 'lib/decision_review/utilities/pdf_validation/configuration.rb', line 38

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.response :betamocks if mock_enabled?
    faraday.response :json
    faraday.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.

[View source] [View on GitHub]

16
17
18
# File 'lib/decision_review/utilities/pdf_validation/configuration.rb', line 16

def service_name
  'DecisionReview::PDFValidation'
end