Class: EVSSClaimService
Overview
Constant Summary
collapse
- EVSS_CLAIM_KEYS =
%w[open_claims historical_claims].freeze
Instance Method Summary
collapse
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
Constructor Details
Returns a new instance of EVSSClaimService.
12
13
14
|
# File 'app/services/evss_claim_service.rb', line 12
def initialize(user)
@user = user
end
|
Instance Method Details
#all ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/services/evss_claim_service.rb', line 16
def all
raw_claims = client.all_claims.body
claims = EVSS_CLAIM_KEYS.each_with_object([]) do |key, claim_accum|
next unless raw_claims[key]
claim_accum << raw_claims[key].map do |raw_claim|
create_or_update_claim(raw_claim)
end
end.flatten
[claims, true]
rescue Breakers::OutageException, EVSS::ErrorMiddleware::EVSSBackendServiceError
[claims_scope.all, false]
end
|
96
97
98
|
# File 'app/services/evss_claim_service.rb', line 96
def
@auth_headers ||= EVSS::AuthHeaders.new(@user).to_h
end
|
#bgs_service ⇒ Object
81
82
83
84
|
# File 'app/services/evss_claim_service.rb', line 81
def bgs_service
@bgs ||= BGS::Services.new(external_uid: @user.participant_id,
external_key: @user.participant_id)
end
|
#claims_scope ⇒ Object
127
128
129
|
# File 'app/services/evss_claim_service.rb', line 127
def claims_scope
EVSSClaim.for_user(@user)
end
|
#client ⇒ Object
92
93
94
|
# File 'app/services/evss_claim_service.rb', line 92
def client
@client ||= EVSS::ClaimsService.new()
end
|
#create_or_update_claim(raw_claim) ⇒ Object
131
132
133
134
135
136
137
138
139
140
141
|
# File 'app/services/evss_claim_service.rb', line 131
def create_or_update_claim(raw_claim)
claim = claims_scope.where(evss_id: raw_claim['id']).first
if claim.blank?
claim = EVSSClaim.new(user_uuid: @user.uuid,
user_account: @user.user_account,
evss_id: raw_claim['id'],
data: {})
end
claim.update(list_data: raw_claim)
claim
end
|
#get_claim(claim_id) ⇒ Object
86
87
88
89
90
|
# File 'app/services/evss_claim_service.rb', line 86
def get_claim(claim_id)
bgs_service.ebenefits_benefit_claims_status.find_benefit_claim_details_by_benefit_claim_id(
benefit_claim_id: claim_id
)
end
|
#record_workaround(task, claim_id, job_id) ⇒ Object
118
119
120
121
122
123
124
125
|
# File 'app/services/evss_claim_service.rb', line 118
def record_workaround(task, claim_id, job_id)
::Rails.logger.info('Supplementing EVSS headers', {
message_type: "evss.#{task}.no_birls_id",
claim_id:,
job_id:,
revision: 2
})
end
|
#request_decision(claim) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
|
# File 'app/services/evss_claim_service.rb', line 41
def request_decision(claim)
= .clone
= (claim.evss_id, )
job_id = EVSS::RequestDecision.perform_async(, claim.evss_id)
record_workaround('request_decision', claim.evss_id, job_id) if
job_id
end
|
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'app/services/evss_claim_service.rb', line 100
def (claim_id, )
= ['va_eauth_birlsfilenumber'].blank?
if
claim = get_claim(claim_id)
veteran_participant_id = claim[:benefit_claim_details_dto][:ptcpnt_vet_id]
['va_eauth_pid'] = veteran_participant_id
['va_eauth_birlsfilenumber'] = ['va_eauth_pnid']
end
end
|
#update_from_remote(claim) ⇒ Object
30
31
32
33
34
35
36
37
38
39
|
# File 'app/services/evss_claim_service.rb', line 30
def update_from_remote(claim)
begin
raw_claim = client.find_claim_by_id(claim.evss_id).body.fetch('claim', {})
claim.update(data: raw_claim)
successful_sync = true
rescue Breakers::OutageException, EVSS::ErrorMiddleware::EVSSBackendServiceError
successful_sync = false
end
[claim, successful_sync]
end
|
#upload_document(evss_claim_document) ⇒ Object
upload file to s3 and enqueue job to upload to EVSS, used by Claim Status Tool EVSS::DocumentsService is where the uploading of documents actually happens
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'app/services/evss_claim_service.rb', line 55
def upload_document(evss_claim_document)
uploader = EVSSClaimDocumentUploader.new(@user.user_account_uuid, evss_claim_document.uploader_ids)
uploader.store!(evss_claim_document.file_obj)
evss_claim_document.file_name = uploader.final_filename
= .clone
= (evss_claim_document.evss_claim_id, )
job_id = EVSS::DocumentUpload.perform_async(, @user.user_account_uuid,
evss_claim_document.to_serializable_hash)
record_workaround('document_upload', evss_claim_document.evss_claim_id, job_id) if
job_id
rescue CarrierWave::IntegrityError => e
log_exception_to_sentry(e, nil, nil, 'warn')
raise Common::Exceptions::UnprocessableEntity.new(
detail: e.message, source: 'EVSSClaimService.upload_document'
)
end
|