Skip to content

Commit

Permalink
Allow Vet File Update via Claim Evidence API
Browse files Browse the repository at this point in the history
  • Loading branch information
tradesmanhelix committed Jul 16, 2024
1 parent 19297a4 commit 2cf7389
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
21 changes: 18 additions & 3 deletions app/services/external_api/vbms_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,24 @@ def self.fetch_document_series_for(appeal)
end

def self.update_document_in_vbms(appeal, uploadable_document)
@vbms_client ||= init_vbms_client
response = initialize_update(appeal, uploadable_document)
update_document(appeal.veteran_file_number, response.updated_document_token, uploadable_document.pdf_location)
if FeatureToggle.enabled?(:use_ce_api)
file_update_payload = Models::FileUpdatePayload.new(
date_va_received_document: Time.zone.now,
document_type_id: uploadable_document.document_type_id,
file_content: File.read(uploadable_document.pdf_location),
file_content_source: uploadable_document.source
)

VeteranFileUpdater.update_veteran_file(
veteran_file_number: appeal.veteran_file_number,
file_uuid: uploadable_document.document_version_reference_id,
file_update_payload: file_update_payload
)
else
@vbms_client ||= init_vbms_client
response = initialize_update(appeal, uploadable_document)
update_document(appeal.veteran_file_number, response.updated_document_token, uploadable_document.pdf_location)
end
end

def self.upload_document_to_vbms(appeal, uploadable_document)
Expand Down
3 changes: 3 additions & 0 deletions config/initializers/ruby_claim_evidence_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

VeteranFileFetcher = ExternalApi::VeteranFileFetcher
.new(use_canned_api_responses: ApplicationController.dependencies_faked?, logger: Rails.logger)

VeteranFileUpdater = ExternalApi::VeteranFileUpdater
.new(use_canned_api_responses: ApplicationController.dependencies_faked?, logger: Rails.logger)
33 changes: 33 additions & 0 deletions spec/services/external_api/vbms_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,37 @@
end
end
end

describe ".update_document_in_vbms" do
context "with use_ce_api feature toggle enabled" do
before { FeatureToggle.enable!(:use_ce_api) }
after { FeatureToggle.disable!(:use_ce_api) }

let(:fake_document) do
instance_double(
UpdateDocumentInVbms,
document_type_id: 1,
pdf_location: "/path/to/test/location",
source: "my_source",
document_version_reference_id: "12345"
)
end
let(:appeal) { create(:appeal) }
let(:mock_file_update_payload) { instance_double(Models::FileUpdatePayload) }

it "calls the CE API" do
expect(File).to receive(:read).and_return("pdf byte string")
expect(Models::FileUpdatePayload).to receive(:new).and_return(mock_file_update_payload)
expect(VeteranFileUpdater)
.to receive(:update_veteran_file)
.with(
veteran_file_number: appeal.veteran_file_number,
file_uuid: "12345",
file_update_payload: mock_file_update_payload
)

described.update_document_in_vbms(appeal, fake_document)
end
end
end
end

0 comments on commit 2cf7389

Please sign in to comment.