Skip to content

Commit 82cc027

Browse files
authored
LSS 123487 ClaimsEvidence Files service functions (#25382)
1 parent bd35f49 commit 82cc027

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

modules/claims_evidence_api/lib/claims_evidence_api/service/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
module ClaimsEvidenceApi
1111
module Service
1212
# Base service class for API
13-
class Base < Common::Client::Base
13+
class Base < ::Common::Client::Base
1414
configuration ClaimsEvidenceApi::Configuration
1515

1616
include ClaimsEvidenceApi::Exceptions::Service

modules/claims_evidence_api/lib/claims_evidence_api/service/files.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def update(uuid, provider_data: {})
5151
# POST overwrite a file in a vbms folder, but retain the uuid
5252
# @see https://fwdproxy-prod.vfs.va.gov:4469/api/v1/rest/swagger-ui.html#/File/update
5353
#
54+
# @param uuid [String] The UUID of the file data
5455
# @param file_path [String] the path to the file to upload
5556
# @param provider_data [Hash] metadata to be associated with the file
5657
def overwrite(uuid, file_path, provider_data:)
@@ -64,6 +65,26 @@ def overwrite(uuid, file_path, provider_data:)
6465
perform :post, "files/#{uuid}", params, headers
6566
end
6667

68+
# GET retrieve the associated period of service record to from a document
69+
# @see https://fwdproxy-prod.vfs.va.gov:4469/api/v1/rest/swagger-ui.html#/Period%20Of%20Service
70+
#
71+
# only certain documents will have associated period of service records
72+
#
73+
# @param uuid [String] The UUID of the file data
74+
def period_of_service(uuid)
75+
perform :get, "files/#{uuid}/periodOfService", {}
76+
end
77+
78+
# GET file content for a given version as a pdf
79+
# @see https://fwdproxy-prod.vfs.va.gov:4469/api/v1/rest/swagger-ui.html#/Version%20Content
80+
#
81+
# @param uuid [String] The UUID of the file data
82+
# @param version [String] version UUID of the file data
83+
def download(uuid, version)
84+
headers = { 'Accept' => 'application/pdf' }
85+
perform :get, "files/#{uuid}/#{version}/content", {}, headers
86+
end
87+
6788
private
6889

6990
# @see ClaimsEvidenceApi::Service::Base#endpoint

modules/claims_evidence_api/spec/lib/claims_evidence_api/service/files_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
let(:headers) { { 'X-Folder-URI' => folder_identifier } }
1515

1616
let(:uuid) { SecureRandom.hex }
17+
let(:version) { SecureRandom.hex }
1718
let(:file_path) { Common::FileHelpers.generate_random_file('TEST FILE', '.test') }
1819
let(:file_name) { File.basename(file_path) }
1920
let(:provider_data) do
@@ -120,4 +121,21 @@
120121
expect { service.overwrite(uuid, file_path, provider_data: {}) }.to raise_error JSON::Schema::ValidationError
121122
end
122123
end
124+
125+
describe '#period_of_service' do
126+
it 'performs a GET' do
127+
path = "files/#{uuid}/periodOfService"
128+
expect(service).to receive(:perform).with(:get, path, {})
129+
service.period_of_service(uuid)
130+
end
131+
end
132+
133+
describe '#download' do
134+
it 'performs a GET for a specific file version' do
135+
download_headers = { 'Accept' => 'application/pdf' }
136+
path = "files/#{uuid}/#{version}/content"
137+
expect(service).to receive(:perform).with(:get, path, {}, download_headers)
138+
service.download(uuid, version)
139+
end
140+
end
123141
end

0 commit comments

Comments
 (0)