Class: VAProfile::Profile::V3::Service

Inherits:
Common::Client::Base show all
Defined in:
lib/va_profile/profile/v3/service.rb

Overview

NOTE: This controller is used for discovery purposes. Please contact the Authenticated Experience Profile team before using.

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#initialize(user) ⇒ Service

Returns a new instance of Service.



21
22
23
24
# File 'lib/va_profile/profile/v3/service.rb', line 21

def initialize(user)
  @user = user
  super()
end

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



19
20
21
# File 'lib/va_profile/profile/v3/service.rb', line 19

def user
  @user
end

Instance Method Details

#bodyObject (private)



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/va_profile/profile/v3/service.rb', line 60

def body
  {
    bios: [
      { bioPath: 'militaryPerson.adminDecisions' },
      { bioPath: 'militaryPerson.adminEpisodes' },
      { bioPath: 'militaryPerson.dentalIndicators' },
      { bioPath: 'militaryPerson.militaryOccupations', parameters: { scope: 'all' } },
      { bioPath: 'militaryPerson.militaryServiceHistory', parameters: { scope: 'all' } },
      { bioPath: 'militaryPerson.militarySummary' },
      { bioPath: 'militaryPerson.militarySummary.customerType.dodServiceSummary' },
      { bioPath: 'militaryPerson.payGradeRanks', parameters: { scope: 'highest' } },
      { bioPath: 'militaryPerson.prisonerOfWars' },
      { bioPath: 'militaryPerson.transferOfEligibility' },
      { bioPath: 'militaryPerson.retirements' },
      { bioPath: 'militaryPerson.separationPays' },
      { bioPath: 'militaryPerson.retirementPays' },
      { bioPath: 'militaryPerson.combatPays' },
      { bioPath: 'militaryPerson.unitAssignments' }
    ]
  }
end

#get_health_benefit_bioObject



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

def get_health_benefit_bio
  oid = MPI::Constants::VA_ROOT_OID
  path = "#{oid}/#{ERB::Util.url_encode(icn_with_aaid)}"
  service_response = perform(:post, path, { bios: [{ bioPath: 'healthBenefit' }] })
  response = VAProfile::Profile::V3::HealthBenefitBioResponse.new(service_response)
  Sentry.set_extras(response.debug_data) unless response.ok?
  code = response.code || 502
  raise_backend_exception("VET360_#{code}", self.class) if response.server_error?
  response
end

#get_military_infoObject



37
38
39
# File 'lib/va_profile/profile/v3/service.rb', line 37

def get_military_info
  config.submit(path(@user.edipi), body)
end

#get_military_occupationsObject



41
42
43
44
45
# File 'lib/va_profile/profile/v3/service.rb', line 41

def get_military_occupations
  builder = VAProfile::Profile::V3::BioPathBuilder.new(:military_occupations)
  response = submit(builder.params)
  VAProfile::Profile::V3::MilitaryOccupationResponse.new(response)
end

#icn_with_aaidObject (private)



53
54
55
56
57
58
# File 'lib/va_profile/profile/v3/service.rb', line 53

def icn_with_aaid
  return "#{user.idme_uuid}^PN^200VIDM^USDVA" if user.idme_uuid
  return "#{user.logingov_uuid}^PN^200VLGN^USDVA" if user.logingov_uuid

  nil
end

#path(edipi) ⇒ Object (private)



82
83
84
# File 'lib/va_profile/profile/v3/service.rb', line 82

def path(edipi)
  "#{OID}/#{ERB::Util.url_encode("#{edipi}#{AAID}")}"
end

#submit(params) ⇒ Object



47
48
49
# File 'lib/va_profile/profile/v3/service.rb', line 47

def submit(params)
  config.submit(path(@user.edipi), params)
end