Class: EVSSSupplementalDocumentUploadProvider
- Inherits:
-
Object
- Object
- EVSSSupplementalDocumentUploadProvider
- Includes:
- SupplementalDocumentUploadProvider
- Defined in:
- lib/disability_compensation/providers/document_upload/evss_supplemental_document_upload_provider.rb
Constant Summary collapse
- STATSD_PROVIDER_METRIC =
'evss_supplemental_document_upload_provider'
Constants included from SupplementalDocumentUploadProvider
SupplementalDocumentUploadProvider::STASTD_UPLOAD_JOB_FAILED_METRIC, SupplementalDocumentUploadProvider::STATSD_ATTEMPT_METRIC, SupplementalDocumentUploadProvider::STATSD_FAILED_METRIC, SupplementalDocumentUploadProvider::STATSD_SUCCESS_METRIC
Instance Method Summary collapse
- #base_logging_info ⇒ Object private
-
#generate_upload_document(file_name) ⇒ EVSSClaimDocument
Uploads to EVSS via the EVSS::DocumentsService require both the file body and an instance of EVSSClaimDocument, so we have to generate and validate that first.
-
#initialize(form526_submission, va_document_type, statsd_metric_prefix, supporting_evidence_attachment = nil) ⇒ EVSSSupplementalDocumentUploadProvider
constructor
the document attachment itself.
- #log_upload_attempt ⇒ Object private
- #log_upload_failure ⇒ Object private
- #log_upload_success ⇒ Object private
-
#log_uploading_job_failure(uploading_job_class, error_class, error_message) ⇒ Object
To call in the sidekiq_retries_exhausted block of the including job This is meant to log an upload attempt that was retried and eventually given up on, so we can investigate the failure in Datadog.
-
#submit_upload_document(evss_claim_document, file_body) ⇒ Faraday::Response
Initializes and uploads via our EVSS Document Service API wrapper.
-
#validate_upload_document(evss_claim_document) ⇒ Object
Takes the necessary validation steps to ensure the document metadata is sufficient for submission to EVSS.
Methods included from SupplementalDocumentUploadProvider
generate_upload_document, log_upload_failure, log_upload_success, raise_not_implemented_error, submit_upload_document, validate_upload_document
Constructor Details
#initialize(form526_submission, va_document_type, statsd_metric_prefix, supporting_evidence_attachment = nil) ⇒ EVSSSupplementalDocumentUploadProvider
the document attachment itself.
15 16 17 18 19 20 21 |
# File 'lib/disability_compensation/providers/document_upload/evss_supplemental_document_upload_provider.rb', line 15 def initialize(form526_submission, va_document_type, statsd_metric_prefix, = nil) @form526_submission = form526_submission @va_document_type = va_document_type @statsd_metric_prefix = statsd_metric_prefix # Unused for EVSS uploads: @supporting_evidence_attachment = end |
Instance Method Details
#base_logging_info ⇒ Object (private)
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/disability_compensation/providers/document_upload/evss_supplemental_document_upload_provider.rb', line 92 def base_logging_info { class: 'EVSSSupplementalDocumentUploadProvider', submitted_claim_id: @form526_submission.submitted_claim_id, submission_id: @form526_submission.id, user_uuid: @form526_submission.user_uuid, va_document_type_code: @va_document_type, primary_form: 'Form526' } end |
#generate_upload_document(file_name) ⇒ EVSSClaimDocument
Uploads to EVSS via the EVSS::DocumentsService require both the file body and an instance of EVSSClaimDocument, so we have to generate and validate that first. Note the EVSSClaimDocument class name is a misnomer; it is more accurately described as an assembly of file-related EVSS metadata, not the actual uploaded file itself
30 31 32 33 34 35 36 |
# File 'lib/disability_compensation/providers/document_upload/evss_supplemental_document_upload_provider.rb', line 30 def generate_upload_document(file_name) EVSSClaimDocument.new( evss_claim_id: @form526_submission.submitted_claim_id, document_type: @va_document_type, file_name: ) end |
#log_upload_attempt ⇒ Object (private)
103 104 105 106 |
# File 'lib/disability_compensation/providers/document_upload/evss_supplemental_document_upload_provider.rb', line 103 def log_upload_attempt Rails.logger.info('EVSSSupplementalDocumentUploadProvider upload attempted', base_logging_info) StatsD.increment("#{@statsd_metric_prefix}.#{STATSD_PROVIDER_METRIC}.#{STATSD_ATTEMPT_METRIC}") end |
#log_upload_failure ⇒ Object (private)
113 114 115 116 |
# File 'lib/disability_compensation/providers/document_upload/evss_supplemental_document_upload_provider.rb', line 113 def log_upload_failure Rails.logger.error('EVSSSupplementalDocumentUploadProvider upload failed', base_logging_info) StatsD.increment("#{@statsd_metric_prefix}.#{STATSD_PROVIDER_METRIC}.#{STATSD_FAILED_METRIC}") end |
#log_upload_success ⇒ Object (private)
108 109 110 111 |
# File 'lib/disability_compensation/providers/document_upload/evss_supplemental_document_upload_provider.rb', line 108 def log_upload_success Rails.logger.info('EVSSSupplementalDocumentUploadProvider upload successful', base_logging_info) StatsD.increment("#{@statsd_metric_prefix}.#{STATSD_PROVIDER_METRIC}.#{STATSD_SUCCESS_METRIC}") end |
#log_uploading_job_failure(uploading_job_class, error_class, error_message) ⇒ Object
To call in the sidekiq_retries_exhausted block of the including job This is meant to log an upload attempt that was retried and eventually given up on, so we can investigate the failure in Datadog
(e.g. UploadBDDInstructions)
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/disability_compensation/providers/document_upload/evss_supplemental_document_upload_provider.rb', line 76 def log_uploading_job_failure(uploading_job_class, error_class, ) Rails.logger.error( "#{uploading_job_class} EVSSSupplementalDocumentUploadProvider Failure", { **base_logging_info, uploading_job_class:, error_class:, error_message: } ) StatsD.increment("#{@statsd_metric_prefix}.#{STATSD_PROVIDER_METRIC}.#{STASTD_UPLOAD_JOB_FAILED_METRIC}") end |
#submit_upload_document(evss_claim_document, file_body) ⇒ Faraday::Response
Initializes and uploads via our EVSS Document Service API wrapper
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/disability_compensation/providers/document_upload/evss_supplemental_document_upload_provider.rb', line 53 def submit_upload_document(evss_claim_document, file_body) log_upload_attempt client = EVSS::DocumentsService.new(@form526_submission.auth_headers) client.upload(file_body, evss_claim_document) # EVSS::DocumentsService uploads throw a EVSS::ErrorMiddleware::EVSSError if they fail # If no exception is raised, log a success response log_upload_success rescue EVSS::ErrorMiddleware::EVSSError => e # If exception is raised, log and re-raise the error log_upload_failure raise e end |
#validate_upload_document(evss_claim_document) ⇒ Object
Takes the necessary validation steps to ensure the document metadata is sufficient for submission to EVSS
43 44 45 |
# File 'lib/disability_compensation/providers/document_upload/evss_supplemental_document_upload_provider.rb', line 43 def validate_upload_document(evss_claim_document) evss_claim_document.valid? end |