Class: EVSS::VSOSearch::Service

Inherits:
Service show all
Defined in:
lib/evss/vso_search/service.rb

Overview

Proxy Service for VSO search

Examples:

Create a service and fetching current info for a user

vso_search_response = VSOSearch::Service.new.get_current_info

Constant Summary

Constants inherited from Service

Service::STATSD_KEY_PREFIX

Instance Attribute Summary

Attributes inherited from Service

#transaction_id

Instance Method Summary collapse

Methods inherited from Service

#handle_error, #headers, #initialize, #perform, #save_error_details, service_is_up?, #with_monitoring_and_error_handling

Methods included from Common::Client::Concerns::Monitoring

#increment, #increment_failure, #increment_total, #with_monitoring

Methods inherited from Common::Client::Base

#config, configuration, #connection, #delete, #get, #perform, #post, #put, #raise_backend_exception, #raise_not_authenticated, #request, #sanitize_headers!, #service_name

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata

Constructor Details

This class inherits a constructor from EVSS::Service

Instance Method Details

#get_current_info(additional_headers = {}) ⇒ Faraday::Response

Returns current info for a user by their SSN

Parameters:

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

    Any additional HTTP headers you want to include in the request.

Returns:

  • (Faraday::Response)

    Faraday response instance



23
24
25
26
27
# File 'lib/evss/vso_search/service.rb', line 23

def get_current_info(additional_headers = {})
  with_monitoring_and_error_handling do
    perform(:post, 'getCurrentInfo', '', request_headers(additional_headers)).body
  end
end

#request_headers(additional_headers) ⇒ Object (private)



31
32
33
34
35
36
37
38
39
40
# File 'lib/evss/vso_search/service.rb', line 31

def request_headers(additional_headers)
  edipi = additional_headers['va_eauth_dodedipnid'].presence || @user&.edipi
  ssn = additional_headers['va_eauth_pnid'].presence || @user&.ssn
  {
    'ssn' => ssn,
    'edipi' => edipi,
    'Authorization' => "Token token=#{Settings.caseflow.app_token}",
    'Content-Type' => 'application/json'
  }.merge(additional_headers)
end