Class: EVSS::DocumentsService

Inherits:
BaseService show all
Defined in:
lib/evss/documents_service.rb

Constant Summary collapse

API_VERSION =
Settings.evss.versions.documents
BASE_URL =
"#{Settings.evss.url}/wss-document-services-web-#{API_VERSION}/rest/".freeze
DEFAULT_TIMEOUT =

this service is only used from an async worker so long timeout is acceptable here

480

Constants inherited from BaseService

BaseService::SYSTEM_NAME

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseService

#base_url, #cert?, #client_cert, #client_key, #conn, create_breakers_service, #get, #initialize, #post, #root_ca, #ssl_options, #timeout

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata

Constructor Details

This class inherits a constructor from EVSS::BaseService

Class Method Details

.breakers_serviceObject



33
34
35
# File 'lib/evss/documents_service.rb', line 33

def self.breakers_service
  BaseService.create_breakers_service(name: 'EVSS/Documents', url: BASE_URL)
end

Instance Method Details

#get_claim_documents(claim_id) ⇒ Object



29
30
31
# File 'lib/evss/documents_service.rb', line 29

def get_claim_documents(claim_id)
  get "documents/getClaimDocuments/#{claim_id}"
end

#upload(file_body, document_data) ⇒ Object

seconds



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/evss/documents_service.rb', line 13

def upload(file_body, document_data)
  headers = { 'Content-Type' => 'application/octet-stream' }
  Timeout.timeout(DEFAULT_TIMEOUT) do
    post 'queuedDocumentUploadService/ajaxUploadFile', file_body, headers do |req|
      req.params['systemName'] = SYSTEM_NAME
      req.params['docType'] = document_data.document_type
      req.params['docTypeDescription'] = document_data.description
      req.params['claimId'] = document_data.evss_claim_id
      # In theory one document can correspond to multiple tracked items
      # To do that, add multiple query parameters
      req.params['trackedItemIds'] = document_data.tracked_item_id
      req.params['qqfile'] = document_data.file_name
    end
  end
end