Class: VAProfile::Profile::V3::Configuration
- Inherits:
-
Common::Client::Configuration::REST
- Object
- Common::Client::Configuration::Base
- Common::Client::Configuration::REST
- VAProfile::Profile::V3::Configuration
- 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
-
#base_path ⇒ String
Base path for direct_deposit URLs.
-
#connection ⇒ Faraday::Connection
Creates a Faraday connection with parsing json and breakers functionality.
-
#post(path, body = {}) ⇒ Faraday::Response
(also: #submit)
Response from POST request.
-
#service_name ⇒ String
Service name to use in breakers and metrics.
-
#use_mocks? ⇒ Boolean
private
Should the service use mock data in lower environments.
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
Instance Method Details
#base_path ⇒ String
Returns 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 |
#connection ⇒ Faraday::Connection
Creates a Faraday connection with parsing json and breakers functionality.
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/va_profile/profile/v3/configuration.rb', line 45 def connection @conn ||= Faraday.new(base_path, headers: base_request_headers, request: ) do |faraday| faraday.use :breakers faraday.request :json faraday.response :betamocks if use_mocks? faraday.response :snakecase, symbolize: false faraday.response :json, content_type: /\bjson/ faraday.adapter Faraday.default_adapter end end |
#post(path, body = {}) ⇒ Faraday::Response Also known as: submit
Returns 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_name ⇒ String
Returns 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 |
#use_mocks? ⇒ Boolean (private)
Returns Should the service use mock data in lower environments.
63 64 65 |
# File 'lib/va_profile/profile/v3/configuration.rb', line 63 def use_mocks? VAProfile::Configuration::SETTINGS.military_personnel.use_mocks || false end |