Class: VAProfile::MilitaryPersonnel::Service

Inherits:
Service show all
Includes:
Common::Client::Concerns::Monitoring
Defined in:
lib/va_profile/military_personnel/service.rb

Constant Summary collapse

OID =
'2.16.840.1.113883.3.42.10001.100001.12'
AAID =
'^NI^200DOD^USDOD'

Constants inherited from Service

Service::STATSD_KEY_PREFIX

Instance Method Summary collapse

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

#with_monitoring

Methods inherited from Service

breakers_service, #initialize, #perform

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

This class inherits a constructor from VAProfile::Service

Instance Method Details

#get_service_historyVAProfile::MilitaryPersonnel::ServiceHistoryResponse

GET’s a user’s military service history from the VAProfile API If a user is not found in VAProfile, an empty ServiceHistoryResponse with a 404 status will be returned

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/va_profile/military_personnel/service.rb', line 24

def get_service_history
  with_monitoring do
    edipi_present!

    response = perform(:post, identity_path, VAProfile::Models::ServiceHistory.in_json)

    ServiceHistoryResponse.from(@current_user, response)
  end
rescue Common::Client::Errors::ClientError => e
  error_status = e.status
  if error_status == 404
    log_exception_to_sentry(
      e, { edipi: @user.edipi }, { va_profile: :service_history_not_found }, :warning
    )

    return ServiceHistoryResponse.new(404, episodes: nil)
  elsif error_status && error_status >= 400 && error_status < 500
    return ServiceHistoryResponse.new(error_status, episodes: nil)
  end

  # Sometimes e.status is nil. Why?
  Rails.logger.info('Miscellaneous service history error', error: e)
  handle_error(e)
rescue => e
  handle_error(e)
end

#identity_pathObject

VA Profile military_personnel endpoints use the OID (Organizational Identifier), the EDIPI, and the Assigning Authority ID to identify which person will be updated/retrieved.



53
54
55
# File 'lib/va_profile/military_personnel/service.rb', line 53

def identity_path
  "#{OID}/#{ERB::Util.url_encode(edipi_with_aaid.to_s)}"
end