Class: VAProfile::Profile::V3::Configuration

Inherits:
Common::Client::Configuration::REST show all
Defined in:
lib/va_profile/profile/v3/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.

Constant Summary collapse

PROFILE_V3_PATH =
'profile-service/profile/v3'

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_pathString

Returns Base path for direct_deposit URLs.

Returns:

  • (String)

    Base path for direct_deposit URLs.



20
21
22
# File 'lib/va_profile/profile/v3/configuration.rb', line 20

def base_path
  "#{VAProfile::Configuration::SETTINGS.url}/#{PROFILE_V3_PATH}"
end

#connectionFaraday::Connection

Creates a Faraday connection with parsing json and breakers functionality.

Returns:

  • (Faraday::Connection)

    a Faraday connection instance.



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/va_profile/profile/v3/configuration.rb', line 43

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

    faraday.response :betamocks if use_mocks?
    faraday.response :json, content_type: /\bjson/

    faraday.adapter Faraday.default_adapter
  end
end

#post(path, body = {}) ⇒ Faraday::Response

Returns response from POST request.

Returns:

  • (Faraday::Response)

    response from POST request



34
35
36
# File 'lib/va_profile/profile/v3/configuration.rb', line 34

def post(path, body = {})
  connection.post(path, body)
end

#service_nameString

Returns Service name to use in breakers and metrics.

Returns:

  • (String)

    Service name to use in breakers and metrics.



27
28
29
# File 'lib/va_profile/profile/v3/configuration.rb', line 27

def service_name
  'VAPROFILE_PROFILE_V3'
end