Class: EVSSClaimService
- Inherits:
-
Object
- Object
- EVSSClaimService
- Includes:
- SentryLogging
- Defined in:
- app/services/evss_claim_service.rb
Overview
EVSS Claims Status Tool
Constant Summary collapse
- EVSS_CLAIM_KEYS =
%w[open_claims historical_claims].freeze
Instance Method Summary collapse
- #all ⇒ Object
-
#initialize(user) ⇒ EVSSClaimService
constructor
A new instance of EVSSClaimService.
- #request_decision(claim) ⇒ Object
- #update_from_remote(claim) ⇒ Object
-
#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.
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger
Constructor Details
#initialize(user) ⇒ EVSSClaimService
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 |
#request_decision(claim) ⇒ Object
41 42 43 |
# File 'app/services/evss_claim_service.rb', line 41 def request_decision(claim) EVSS::RequestDecision.perform_async(auth_headers, claim.evss_id) 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
47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/services/evss_claim_service.rb', line 47 def upload_document(evss_claim_document) uploader = EVSSClaimDocumentUploader.new(@user.uuid, evss_claim_document.uploader_ids) uploader.store!(evss_claim_document.file_obj) # the uploader sanitizes the filename before storing, so set our doc to match evss_claim_document.file_name = uploader.final_filename EVSS::DocumentUpload.perform_async(auth_headers, @user.uuid, evss_claim_document.to_serializable_hash) rescue CarrierWave::IntegrityError => e log_exception_to_sentry(e, nil, nil, 'warn') raise Common::Exceptions::UnprocessableEntity.new(detail: e., source: 'EVSSClaimService.upload_document') end |