Class: VeteranVerification::Configuration

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

Constant Summary collapse

API_SCOPES =
%w[disability_rating.read].freeze
VETERAN_VERIFICATION_PATH =
'services/veteran_verification/v2'
TOKEN_PATH =
'oauth2/veteran-verification/system/v1/token'

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, #request_options, #service_exception

Instance Method Details

#base_api_path(host = nil) ⇒ Object



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

def base_api_path(host = nil)
  "#{base_path(host)}/#{VETERAN_VERIFICATION_PATH}"
end

#base_path(host = nil) ⇒ String

Returns Base path for veteran_verification URLs.

Parameters:

  • host (String) (defaults to: nil)

    (optional): a configurable base url host if the client application does not want to use the default

Returns:

  • (String)

    Base path for veteran_verification URLs.



27
28
29
# File 'lib/lighthouse/veteran_verification/configuration.rb', line 27

def base_path(host = nil)
  (host || settings.host).to_s
end

#connectionFaraday::Connection

Creates a Faraday connection with parsing json and breakers functionality.

Returns:

  • (Faraday::Connection)

    a Faraday connection instance.



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/lighthouse/veteran_verification/configuration.rb', line 74

def connection
  @conn ||= Faraday.new(base_api_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 use_mocks?
    faraday.response :json
    faraday.adapter Faraday.default_adapter
  end
end

#get(path, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {}) ⇒ Object

Parameters:

  • path: (string)

    the endpoint to call

  • lighthouse_client_id: (string)

    client id retrieved from Lighthouse team to call Veteran Verification APIs

  • lighthouse_rsa_key_path: (string)

    the absolute path to the file that the client id was created from

  • options: (hash)

    options to override aud_claim_url, params, and auth_params

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :params (hash)

    body for the request

  • :aud_claim_url (string)

    option to override the aud_claim_url for LH Veteran Verification APIs

  • :auth_params (hash)

    a hash to send in auth params to create the access token such as the launch context

  • :host (string)

    a base host for the Lighthouse API call



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/lighthouse/veteran_verification/configuration.rb', line 52

def get(path, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {})
  connection
    .get(
      path,
      options[:params],
      {
        Authorization: "Bearer #{
          access_token(
            lighthouse_client_id,
            lighthouse_rsa_key_path,
            options
          )
        }"
      }
    )
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/lighthouse/veteran_verification/configuration.rb', line 38

def service_name
  'VeteranVerification'
end

#settingsConfig::Options

Returns Settings for veteran_verification API.

Returns:

  • (Config::Options)

    Settings for veteran_verification API.



18
19
20
# File 'lib/lighthouse/veteran_verification/configuration.rb', line 18

def settings
  Settings.lighthouse.veteran_verification
end