Class: EVSS::DisabilityCompensationForm::Service

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

Overview

Proxy Service for EVSS’s 526 endpoints. A set of VAAFI headers generated from user data must be passed on initialization so that the calls can be authenticated. The disability compensation service requires additional headers so EVSS::DisabilityCompensationAuthHeaders is used to decorate the default EVSS headers AuthHeaders.

Examples:

Create a service

auth_headers = EVSS::AuthHeaders.new(@current_user).to_h
disability_auth_headers = EVSS::DisabilityCompensationAuthHeaders.new(@current_user).add_headers(auth_headers)
EVSS::DisabilityCompensationForm::Service.new(disability_auth_headers)

Direct Known Subclasses

Dvp::Service, NonBreakeredService

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

#headers, #perform, service_is_up?

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

#with_monitoring

Methods inherited from Common::Client::Base

configuration, #raise_backend_exception

Methods included from SentryLogging

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

Constructor Details

#initialize(headers) ⇒ Service

Returns a new instance of Service.

Parameters:



29
30
31
32
# File 'lib/evss/disability_compensation_form/service.rb', line 29

def initialize(headers)
  @headers = headers
  @transaction_id = @headers['va_eauth_service_transaction_id']
end

Instance Method Details

#get_form526(form_content) ⇒ Faraday::Response

Gets a filled out 526ez PDF from EVSS from the same playload of the submit endpoint. Returns PDF stream in response, instead of submitting to auto-establish. This is used in the 526ez backup submission process when auto-establisment errors and is not possible.

Parameters:

Returns:

  • (Faraday::Response)
    • Response from EVSS /getPDF endpoint



72
73
74
75
76
77
78
# File 'lib/evss/disability_compensation_form/service.rb', line 72

def get_form526(form_content)
  with_monitoring_and_error_handling do
    headers = { 'Content-Type' => 'application/json' }
    options = { timeout: Settings.evss.disability_compensation_form.submit_timeout || 355 }
    perform(:post, 'getPDF', form_content, headers, options)
  end
end

#get_rated_disabilitiesEVSS::DisabilityCompensationForm::RatedDisabilitiesResponse

GETs a user’s rated disabilities

Returns:



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/evss/disability_compensation_form/service.rb', line 38

def get_rated_disabilities
  if @headers['va_eauth_birlsfilenumber'].blank?
    Rails.logger.info('Missing `birls_id`', edipi: @headers['va_eauth_dodedipnid'])
  end
  with_monitoring_and_error_handling do
    Rails.cache.fetch("evss_rated_disabilities/#{@headers['va_eauth_dodedipnid']}-#{@headers['va_eauth_pnid']}",
                      expires_in: 30.minutes) do
      raw_response = perform(:get, 'ratedDisabilities')
      RatedDisabilitiesResponse.new(raw_response.status, raw_response)
    end
  end
end

#submit_form526(form_content) ⇒ EVSS::DisabilityCompensationForm::FormSubmitResponse

POSTs a 526 form to the EVSS submit endpoint. EVSS is bound to VBMSs response times and, therefore, the timeout has to be extended to ~6 minutes to match their upstream timeout.

Parameters:

Returns:



57
58
59
60
61
62
63
64
# File 'lib/evss/disability_compensation_form/service.rb', line 57

def submit_form526(form_content)
  with_monitoring_and_error_handling do
    headers = { 'Content-Type' => 'application/json' }
    options = { timeout: Settings.evss.disability_compensation_form.submit_timeout || 355 }
    raw_response = perform(:post, 'submit', form_content, headers, options)
    FormSubmitResponse.new(raw_response.status, raw_response)
  end
end

#validate_form526(form_content) ⇒ Object



80
81
82
83
84
85
86
# File 'lib/evss/disability_compensation_form/service.rb', line 80

def validate_form526(form_content)
  with_monitoring_and_error_handling do
    headers = { 'Content-Type' => 'application/json' }
    options = { timeout: Settings.evss.disability_compensation_form.submit_timeout || 355 }
    perform(:post, 'validate', form_content, headers, options)
  end
end