Class: VAProfile::VeteranStatus::Service

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

Constant Summary collapse

OID =

double check swagger

'2.16.840.1.113883.3.42.10001.100001.12'
AAID =

double check swagger.

'^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_veteran_statusVAProfile::VeteranStatus::VeteranStatusResponse

GET’s a user’s veteran status info from the VAProfile API If a user is not found in VAProfile, an empty VeteranStatusResponse with a 404 status will be returned

Returns:



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/va_profile/veteran_status/service.rb', line 25

def get_veteran_status
  with_monitoring do
    edipi_present!
    response = perform(:post, identity_path, VAProfile::Models::VeteranStatus.in_json)
    VeteranStatusResponse.from(@current_user, response)
  end
rescue Common::Client::Errors::ClientError => e
  handle_client_error(e)
rescue => e
  handle_error(e)
end

#identity_pathObject

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



60
61
62
# File 'lib/va_profile/veteran_status/service.rb', line 60

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

#military_person?Boolean

Returns boolean for user being/not being considered a military person based on their Title 38 Status Code.

Returns:

  • (Boolean)


54
55
56
# File 'lib/va_profile/veteran_status/service.rb', line 54

def military_person?
  title38_status == 'V3' || title38_status == 'V6'
end

#title38_statusString

Returns Title 38 status code.

Returns:

  • (String)

    Title 38 status code



43
44
45
46
47
# File 'lib/va_profile/veteran_status/service.rb', line 43

def title38_status
  result = get_veteran_status&.title38_status_code&.title38_status_code
  Rails.logger.info "VaProfile title38: #{result}"
  result
end

#veteran?Boolean

Returns true if user is a title 38 veteran.

Returns:

  • (Boolean)

    true if user is a title 38 veteran



38
39
40
# File 'lib/va_profile/veteran_status/service.rb', line 38

def veteran?
  title38_status == 'V1'
end