Class: Efolder::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/efolder/service.rb

Overview

Veteran Facing eFolder

This service provides the veteran with methods to both view the contents of their eFolder, and also download the files contained therein.

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ Service

Returns a new instance of Service.



12
13
14
15
16
# File 'lib/efolder/service.rb', line 12

def initialize(user)
  @user = user
  @client = VBMS::Client.from_env_vars(env_name: Settings.vbms.env)
  @bgs_doc_uuids = bgs_doc_uuids
end

Instance Method Details

#get_document(document_id) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/efolder/service.rb', line 28

def get_document(document_id)
  verify_document_in_folder(document_id)

  @client.send_request(
    VBMS::Requests::GetDocumentContent.new(document_id)
  ).content
end

#list_documentsObject



18
19
20
21
22
23
24
25
26
# File 'lib/efolder/service.rb', line 18

def list_documents
  vbms_docs.map do |document|
    if @bgs_doc_uuids.include?(document[:document_id].delete('{}'))
      document.marshal_dump.slice(
        :document_id, :doc_type, :type_description, :received_at
      )
    end
  end.compact
end