Class: EVSS::DocumentUpload
Constant Summary
collapse
- FILENAME_EXTENSION_MATCHER =
/\.\w*$/
- OBFUSCATED_CHARACTER_MATCHER =
/[a-zA-Z\d]/
- DD_ZSF_TAGS =
['service:claim-status', 'function: evidence upload to EVSS'].freeze
- NOTIFY_SETTINGS =
Settings.vanotify.services.benefits_management_tools
- MAILER_TEMPLATE_ID =
NOTIFY_SETTINGS.template_id.evidence_submission_failure_email
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
log_exception_to_sentry, log_message_to_sentry, non_nil_hash?, normalize_level, rails_logger, set_sentry_metadata
wrap_with_logging
Instance Attribute Details
Returns the value of attribute auth_headers.
20
21
22
|
# File 'app/sidekiq/evss/document_upload.rb', line 20
def
@auth_headers
end
|
#document_hash ⇒ Object
Returns the value of attribute document_hash.
20
21
22
|
# File 'app/sidekiq/evss/document_upload.rb', line 20
def document_hash
@document_hash
end
|
#user_uuid ⇒ Object
Returns the value of attribute user_uuid.
20
21
22
|
# File 'app/sidekiq/evss/document_upload.rb', line 20
def user_uuid
@user_uuid
end
|
Class Method Details
96
97
98
99
100
101
102
|
# File 'app/sidekiq/evss/document_upload.rb', line 96
def self.format_issue_instant_for_mailers(issue_instant)
timestamp = Time.at(issue_instant).in_time_zone('America/New_York')
timestamp.strftime('%B %-d, %Y %-l:%M %P %Z').sub(/([ap])m/, '\1.m.')
end
|
.notify_client ⇒ Object
104
105
106
|
# File 'app/sidekiq/evss/document_upload.rb', line 104
def self.notify_client
VaNotify::Service.new(NOTIFY_SETTINGS.api_key)
end
|
.obscured_filename(original_filename) ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'app/sidekiq/evss/document_upload.rb', line 81
def self.obscured_filename(original_filename)
extension = original_filename[FILENAME_EXTENSION_MATCHER]
filename_without_extension = original_filename.gsub(FILENAME_EXTENSION_MATCHER, '')
if filename_without_extension.length > 5
obfuscated_portion = filename_without_extension[3..-3].gsub(OBFUSCATED_CHARACTER_MATCHER, 'X')
filename_without_extension[0..2] + obfuscated_portion + filename_without_extension[-2..] + extension
else
original_filename
end
end
|
Instance Method Details
#clean_up! ⇒ Object
124
125
126
|
# File 'app/sidekiq/evss/document_upload.rb', line 124
def clean_up!
uploader.remove!
end
|
#client ⇒ Object
140
141
142
|
# File 'app/sidekiq/evss/document_upload.rb', line 140
def client
@client ||= EVSS::DocumentsService.new()
end
|
#document ⇒ Object
136
137
138
|
# File 'app/sidekiq/evss/document_upload.rb', line 136
def document
@document ||= EVSSClaimDocument.new(document_hash)
end
|
#file_body ⇒ Object
144
145
146
|
# File 'app/sidekiq/evss/document_upload.rb', line 144
def file_body
@file_body ||= perform_initial_file_read
end
|
70
71
72
73
74
75
76
77
78
79
|
# File 'app/sidekiq/evss/document_upload.rb', line 70
def perform(, user_uuid, document_hash)
@auth_headers =
@user_uuid = user_uuid
@document_hash = document_hash
validate_document!
pull_file_from_cloud!
perform_document_upload_to_evss
clean_up!
end
|
119
120
121
122
|
# File 'app/sidekiq/evss/document_upload.rb', line 119
def perform_document_upload_to_evss
Rails.logger.info('Begining document upload file to EVSS', filesize: file_body.try(:size))
client.upload(file_body, document)
end
|
128
129
130
|
# File 'app/sidekiq/evss/document_upload.rb', line 128
def perform_initial_file_read
uploader.read_for_upload
end
|
#pull_file_from_cloud! ⇒ Object
115
116
117
|
# File 'app/sidekiq/evss/document_upload.rb', line 115
def pull_file_from_cloud!
uploader.retrieve_from_store!(document.file_name)
end
|
#uploader ⇒ Object
132
133
134
|
# File 'app/sidekiq/evss/document_upload.rb', line 132
def uploader
@uploader ||= EVSSClaimDocumentUploader.new(user_uuid, document.uploader_ids)
end
|
#validate_document! ⇒ Object
110
111
112
113
|
# File 'app/sidekiq/evss/document_upload.rb', line 110
def validate_document!
Sentry.set_tags(source: 'claims-status')
raise Common::Exceptions::ValidationErrors unless document.valid?
end
|