Skip to content

department-of-veterans-affairs/ruby_claim_evidence_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ruby_claim_evidence_api

Ruby library for connecting to the Claim Evidence API.

Overview

Currently, this gem is able to interact with the following endpoints of the Claim Evidence API.

GET /documenttypes

Call document_types to retrieve available document types:

ExternalApi::ClaimEvidenceService.document_types

GET /files/{doc_series_id}/data/ocr

Call get_ocr_document(doc.series_id) to get all of the content for a document:

# Assume use of a VBMS Document model
doc = Document.find_by(criteria: "here")

ExternalApi::ClaimEvidenceService.get_ocr_document(doc.series_id)

Testing

In Local Rails Console

Internally, the app uses a Fakes module to mock API behavior. The required setup steps are as follows:

  1. Install and configure devvpn.
    • Information re. how to do this is located internally.
    • Search "Steps to Set Up DevVPN" in the internal document repository or contact your team lead for assistance in locating these instructions.
  2. Add files needed by Faraday.
    1. Access the example certs located here.
    2. Copy the .crt file locally and note the path for later.
    3. Copy the .key file locally and note the path for later.
  3. In your shell, set the following environment variables:
    • JWT_TOKEN:

      • NOTE: Some CE API endpoints need correct user roles in order to get a successful response.
        • For example, calling the OCR endpoint requires that the user attached to the request's JWT have a specific scanner role.
        • More information on available roles can be found by searching for "Policy Description Document" or "PDD" in the project management software.
      • For the Fakes module, JWT tokens do not auto-generate with each request, so you will need to either manually create one or use an existing token.
        • Using an existing token (recommended):
          • Use one of the JWTs from the Postman environments listed here.
        • Creating a new token:
          • Directions and requirements can be found here.
    • BASE_URL:

      • This will depend on the environment you're wanting to test.
      • For example, https://vefs-claimevidence-int.dev.bip.va.gov is the URL for the INT environment.
    • HTTP_PROXY:

      • You need to have an AIDE user and password, which you can find more info on here.
      • The required format is: http://aideusername:[email protected]:9443
    • KEY_LOCATION: Path to .key file from earlier.

    • CERT_LOCATION: Path to .crt file from earlier.

    • CERT_PASSWORD: Use vbmsclient.

  4. Relaunch your shell or source your shell's config file to load the variables you set above.
  5. In your local Rails console, you can now use Fakes::ClaimEvidenceService. For example:
    • Fakes::ClaimEvidenceService.document_types
    • Fakes::ClaimEvidenceService.get_ocr_document(doc.series_id)

In UAT Environments

In many UAT environments, the gem is preconfigured and can be used via ExternalApi::ClaimEvidenceService:

ExternalApi::ClaimEvidenceService.document_types
ExternalApi::ClaimEvidenceService.get_ocr_document(doc.series_id)

Example Usage

Getting All OCR Content for a Document

This will return all of the documents that contain the search word or phrase inside the document:

match_docs = []

person.documents.each do |doc|
  query = ExternalApi::ClaimEvidenceService.get_ocr_document(doc.series_id)
  if query.downcase.include("search term here")
    match_docs << doc
  end
end

About

Ruby library for connecting Claim Evidence API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages