Class: BenefitsDocuments::Form526::UploadSupplementalDocumentService

Inherits:
Object
  • Object
show all
Defined in:
lib/lighthouse/benefits_documents/form526/upload_supplemental_document_service.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_body, lighthouse_document) ⇒ UploadSupplementalDocumentService

Returns a new instance of UploadSupplementalDocumentService.

Parameters:

  • file_body (String)

    content of uploading file

  • lighthouse_document (LighthouseDocument)

    instance of wrapper class for document metadata



23
24
25
26
27
28
# File 'lib/lighthouse/benefits_documents/form526/upload_supplemental_document_service.rb', line 23

def initialize(file_body, lighthouse_document)
  super()

  @file_body = file_body
  @lighthouse_document = lighthouse_document
end

Class Method Details

.callObject



17
18
19
# File 'lib/lighthouse/benefits_documents/form526/upload_supplemental_document_service.rb', line 17

def self.call(*)
  new(*).call
end

Instance Method Details

#callObject

return [Faraday::Response] BenefitsDocuments::WorkerService makes http calls with the Faraday gem under the hood



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/lighthouse/benefits_documents/form526/upload_supplemental_document_service.rb', line 32

def call
  client = BenefitsDocuments::WorkerService.new
  client.upload_document(@file_body, @lighthouse_document)
rescue => e
  # NOTE: third argument, lighthouse_client_id is left nil so it isn't logged.
  error = Lighthouse::ServiceException.send_error(
    e, self.class.to_s.underscore, nil, BenefitsDocuments::Configuration::DOCUMENTS_PATH
  )

  # Lighthouse::ServiceException can either raise an error or return an error object, so we need to
  # assign it to a variable and re-raise it here manually if it is the latter
  raise error
end