Class: Sidekiq::Form526BackupSubmissionProcess::Processor
- Inherits:
-
Object
- Object
- Sidekiq::Form526BackupSubmissionProcess::Processor
- Extended by:
- Logging::ThirdPartyTransaction::MethodWrapper
- Defined in:
- lib/sidekiq/form526_backup_submission_process/processor.rb
Direct Known Subclasses
Constant Summary collapse
- FORM_526 =
'form526'
- FORM_526_DOC_TYPE =
'21-526EZ'
- FORM_526_UPLOADS =
'form526_uploads'
- FORM_526_UPLOADS_DOC_TYPE =
'evidence'
- FORM_4142 =
'form4142'
- FORM_4142_DOC_TYPE =
'21-4142'
- FORM_0781 =
'form0781'
- FORM_8940 =
'form8940'
- FLASHES =
'flashes'
- BKUP_SETTINGS =
Settings.key?(:form526_backup) ? Settings.form526_backup : OpenStruct.new
- DOCTYPE_MAPPING =
{ '21-526EZ' => 'L533', '21-4142' => 'L107', '21-0781' => 'L228', '21-0781a' => 'L229', '21-8940' => 'L149', 'bdd' => 'L023' }.freeze
- DOCTYPE_NAMES =
%w[ 21-526EZ 21-4142 21-0781 21-0781a 21-8940 ].freeze
- SUB_METHOD =
(BKUP_SETTINGS.submission_method || 'single').to_sym
Instance Attribute Summary collapse
-
#docs ⇒ Object
Returns the value of attribute docs.
-
#docs_gathered ⇒ Object
readonly
Returns the value of attribute docs_gathered.
-
#ignore_expiration ⇒ Object
readonly
Returns the value of attribute ignore_expiration.
-
#initial_upload ⇒ Object
readonly
Returns the value of attribute initial_upload.
-
#initial_upload_fetched ⇒ Object
readonly
Returns the value of attribute initial_upload_fetched.
-
#initial_upload_location ⇒ Object
readonly
Returns the value of attribute initial_upload_location.
-
#initial_upload_uuid ⇒ Object
readonly
Returns the value of attribute initial_upload_uuid.
-
#lighthouse_service ⇒ Object
readonly
Returns the value of attribute lighthouse_service.
-
#submission ⇒ Object
readonly
Returns the value of attribute submission.
-
#submission_id ⇒ Object
readonly
Returns the value of attribute submission_id.
-
#zip ⇒ Object
readonly
Returns the value of attribute zip.
Instance Method Summary collapse
- #bdd? ⇒ Boolean
-
#choose_provider(headers, provider, breakered: true) ⇒ Object
82245 - Adding provider to method.
- #convert_doc_to_pdf(doc, klass) ⇒ Object
- #convert_docs_to_pdf ⇒ Object
- #determine_zip ⇒ Object
- #evidence_526_split ⇒ Object
- #gather_docs! ⇒ Object
- #generate_attachments(evidence_files, other_payloads) ⇒ Object
- #generate_zip_and_upload(params_docs, zipname, metadata, return_url, url_life_length) ⇒ Object
- #get_bdd_pdf ⇒ Object
- #get_form0781_pdf ⇒ Object
- #get_form4142_pdf ⇒ Object
- #get_form526_pdf ⇒ Object
- #get_form8940_pdf ⇒ Object
-
#get_form_from_external_api(headers, provider, form_json, transaction_id = nil) ⇒ Object
82245 - Adding provider to method.
-
#get_meta_data(doc_type) ⇒ Object
Generate metadata for metadata.json file for the lighthouse benefits intake API to send along to Central Mail.
- #get_uploads ⇒ Object
-
#initialize(submission_id, docs = [], get_upload_location_on_instantiation: true, ignore_expiration: false) ⇒ Processor
constructor
Takes a submission id, assembles all needed docs from its payload, then sends it to central mail via lighthouse benefits intake API - developer.va.gov/explore/benefits/docs/benefits?version=current.
- #instantiate_upload_info_from_lighthouse ⇒ Object
- #log_info(message:, upload_type:, uuid:) ⇒ Object
- #log_resp(message:, resp:) ⇒ Object
-
#new_s3_resource ⇒ Object
[remediation effort].
- #process! ⇒ Object
- #received_date ⇒ Object
- #return_upload_params_and_docs(form526_doc, attachments) ⇒ Object
-
#s3_bucket ⇒ Object
[remediation effort].
- #send_to_central_mail_through_lighthouse_claims_intake_api! ⇒ Object
- #submit_ancillary_payloads(docs) ⇒ Object
- #submit_as_one(initial_payload, other_payloads = nil, return_docs_instead_of_sending: false) ⇒ Object
- #submit_initial_payload(initial_payload) ⇒ Object
- #submit_to_lh_claims_intake_api(form526_doc, attachments) ⇒ Object
-
#upload_location_to_location_and_uuid(upload_return) ⇒ Object
Transforms the lighthouse response to the only info we actually need from it.
-
#upload_pdf_submission_to_s3(return_url: false, url_life_length: 1.week.to_i) ⇒ Object
- remediation effort
-
This code is to take a 526 submission, generate the pdfs, and upload to aws for manual review.
- #write_to_tmp_file(content, ext = 'pdf') ⇒ Object
Methods included from Logging::ThirdPartyTransaction::MethodWrapper
Constructor Details
#initialize(submission_id, docs = [], get_upload_location_on_instantiation: true, ignore_expiration: false) ⇒ Processor
Takes a submission id, assembles all needed docs from its payload, then sends it to central mail via lighthouse benefits intake API - developer.va.gov/explore/benefits/docs/benefits?version=current
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 69 def initialize(submission_id, docs = [], get_upload_location_on_instantiation: true, ignore_expiration: false) @submission_id = submission_id @submission = Form526Submission.find(submission_id) @user_account = @submission.account @docs = docs @docs_gathered = false @initial_upload_fetched = false @lighthouse_service = Form526BackupSubmission::Service.new @ignore_expiration = ignore_expiration # We need an initial location/uuid as other ancillary docs want a reference id to it # (eventhough I dont think they actually use it for anything because we are just using them to # generate the pdf and not the sending portion of those classes... but it needs something there to not error) instantiate_upload_info_from_lighthouse if get_upload_location_on_instantiation determine_zip end |
Instance Attribute Details
#docs ⇒ Object
Returns the value of attribute docs.
26 27 28 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 26 def docs @docs end |
#docs_gathered ⇒ Object (readonly)
Returns the value of attribute docs_gathered.
23 24 25 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 23 def docs_gathered @docs_gathered end |
#ignore_expiration ⇒ Object (readonly)
Returns the value of attribute ignore_expiration.
23 24 25 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 23 def ignore_expiration @ignore_expiration end |
#initial_upload ⇒ Object (readonly)
Returns the value of attribute initial_upload.
23 24 25 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 23 def initial_upload @initial_upload end |
#initial_upload_fetched ⇒ Object (readonly)
Returns the value of attribute initial_upload_fetched.
23 24 25 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 23 def initial_upload_fetched @initial_upload_fetched end |
#initial_upload_location ⇒ Object (readonly)
Returns the value of attribute initial_upload_location.
23 24 25 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 23 def initial_upload_location @initial_upload_location end |
#initial_upload_uuid ⇒ Object (readonly)
Returns the value of attribute initial_upload_uuid.
23 24 25 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 23 def initial_upload_uuid @initial_upload_uuid end |
#lighthouse_service ⇒ Object (readonly)
Returns the value of attribute lighthouse_service.
23 24 25 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 23 def lighthouse_service @lighthouse_service end |
#submission ⇒ Object (readonly)
Returns the value of attribute submission.
23 24 25 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 23 def submission @submission end |
#submission_id ⇒ Object (readonly)
Returns the value of attribute submission_id.
23 24 25 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 23 def submission_id @submission_id end |
#zip ⇒ Object (readonly)
Returns the value of attribute zip.
23 24 25 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 23 def zip @zip end |
Instance Method Details
#bdd? ⇒ Boolean
315 316 317 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 315 def bdd? submission.form.dig('form526', 'form526', 'bddQualified') || false end |
#choose_provider(headers, provider, breakered: true) ⇒ Object
82245 - Adding provider to method. this should be removed when toxic exposure flipper is removed
438 439 440 441 442 443 444 445 446 447 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 438 def choose_provider(headers, provider, breakered: true) ApiProviderFactory.call( type: ApiProviderFactory::FACTORIES[:generate_pdf], provider:, # this sends the auth headers and if we want the "breakered" or "non-breakered" version options: { auth_headers: headers, breakered: }, current_user: OpenStruct.new({ flipper_id: submission.user_uuid, icn: @user_account.icn }), feature_toggle: ApiProviderFactory::FEATURE_TOGGLE_GENERATE_PDF ) end |
#convert_doc_to_pdf(doc, klass) ⇒ Object
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 421 def convert_doc_to_pdf(doc, klass) actual_path_to_file = @lighthouse_service.get_file_path_from_objs(doc[:file]) file_type_extension = File.extname(actual_path_to_file).downcase if klass::CAN_CONVERT.include?(file_type_extension) ::Rails.logger.info( 'Generating PDF document', { actual_path_to_file:, file_type_extension: } ) doc[:file] = klass.new(actual_path_to_file).converted_filename # delete old pulled down file after converted (in prod, dont delete spec/test files), # dont care about it anymore, the converted file gets deleted later after successful submission Common::FileHelpers.delete_file_if_exists(actual_path_to_file) if ::Rails.env.production? end end |
#convert_docs_to_pdf ⇒ Object
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 403 def convert_docs_to_pdf ::Rails.logger.info( 'Begin 526 PDF Generating for Backup Submission', { submission_id:, initial_upload_uuid: } ) klass = BenefitsIntakeService::Utilities::ConvertToPdf result = docs.each do |doc| convert_doc_to_pdf(doc, klass) end ::Rails.logger.info( 'Complete 526 PDF Generating for Backup Submission', { submission_id:, initial_upload_uuid: } ) result end |
#determine_zip ⇒ Object
304 305 306 307 308 309 310 311 312 313 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 304 def determine_zip z = submission.form.dig('form526', 'form526', 'veteran', 'currentMailingAddress') if z.nil? || z['country']&.downcase != 'usa' @zip = '00000' else z_final = z['zipFirstFive'] z_final += "-#{z['zipLastFour']}" unless z['zipLastFour'].nil? @zip = z_final end end |
#evidence_526_split ⇒ Object
131 132 133 134 135 136 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 131 def evidence_526_split is_526_or_evidence = docs.group_by do |doc| doc[:type] == FORM_526_DOC_TYPE || doc[:type] == FORM_526_UPLOADS_DOC_TYPE end [is_526_or_evidence[true], is_526_or_evidence[false]] end |
#gather_docs! ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 93 def gather_docs! get_form526_pdf # 21-526EZ get_uploads if submission.form[FORM_526_UPLOADS] get_form4142_pdf if submission.form[FORM_4142] get_form0781_pdf if submission.form[FORM_0781] get_form8940_pdf if submission.form[FORM_8940] get_bdd_pdf if bdd? convert_docs_to_pdf # Iterate over self.docs obj and add required metadata to objs directly docs.each { |doc| doc[:metadata] = (doc[:type]) } @docs_gathered = true end |
#generate_attachments(evidence_files, other_payloads) ⇒ Object
226 227 228 229 230 231 232 233 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 226 def (evidence_files, other_payloads) return evidence_files if other_payloads.nil? other_payloads.each do |op| evidence_files << { file: op[:file], file_name: "#{op[:metadata][:docType]}.pdf" } end evidence_files end |
#generate_zip_and_upload(params_docs, zipname, metadata, return_url, url_life_length) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 138 def generate_zip_and_upload(params_docs, zipname, , return_url, url_life_length) zip_path_and_name = "tmp/#{zipname}" Zip::File.open(zip_path_and_name, create: true) do |zipfile| zipfile.get_output_stream('metadata.json') { |f| f.puts .to_json } zipfile.get_output_stream('mappings.json') do |f| f.puts params_docs.to_h { |q| [q[:file_name], q[:docType]] }.to_json end params_docs.each { |doc| zipfile.add(doc[:file_name], doc[:file_path]) } end s3_resource = new_s3_resource obj = s3_resource.bucket(s3_bucket).object(zipname) obj_ret = obj.upload_file(zip_path_and_name, content_type: 'application/zip') if return_url obj.presigned_url(:get, expires_in: url_life_length) else obj_ret end ensure Common::FileHelpers.delete_file_if_exists(zip_path_and_name) end |
#get_bdd_pdf ⇒ Object
395 396 397 398 399 400 401 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 395 def get_bdd_pdf # Move away from EVSS at later date docs << { type: 'bdd', file: 'lib/evss/disability_compensation_form/bdd_instructions.pdf' } end |
#get_form0781_pdf ⇒ Object
383 384 385 386 387 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 383 def get_form0781_pdf # refactor away from EVSS eventually files = EVSS::DisabilityCompensationForm::SubmitForm0781.new.get_docs(submission.id, initial_upload_uuid) docs.concat(files) end |
#get_form4142_pdf ⇒ Object
374 375 376 377 378 379 380 381 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 374 def get_form4142_pdf processor4142 = DecisionReviewV1::Processor::Form4142Processor.new(form_data: submission.form[FORM_4142], submission_id:) docs << { type: FORM_4142_DOC_TYPE, file: processor4142.pdf_path } end |
#get_form526_pdf ⇒ Object
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 325 def get_form526_pdf headers = submission.auth_headers submission_create_date = submission.created_at.iso8601 form_json = submission.form[FORM_526] form_json[FORM_526]['claimDate'] ||= submission_create_date form_json[FORM_526]['applicationExpirationDate'] = 365.days.from_now.iso8601 if @ignore_expiration form_version = submission.saved_claim.parsed_form['startedFormVersion'] if form_version.present? transaction_id = submission.system_transaction_id resp = get_form_from_external_api(headers, ApiProviderFactory::API_PROVIDER[:lighthouse], form_json.to_json, transaction_id) content = resp.env.response_body else resp = get_form_from_external_api(headers, ApiProviderFactory::API_PROVIDER[:evss], form_json.to_json) b64_enc_body = resp.body['pdf'] content = Base64.decode64(b64_enc_body) end file = write_to_tmp_file(content) docs << { type: FORM_526_DOC_TYPE, file: } end |
#get_form8940_pdf ⇒ Object
389 390 391 392 393 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 389 def get_form8940_pdf # refactor away from EVSS eventually file = EVSS::DisabilityCompensationForm::SubmitForm8940.new.get_docs(submission.id) docs << file end |
#get_form_from_external_api(headers, provider, form_json, transaction_id = nil) ⇒ Object
82245 - Adding provider to method. this should be removed when toxic exposure flipper is removed
352 353 354 355 356 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 352 def get_form_from_external_api(headers, provider, form_json, transaction_id = nil) # get the "breakered" version service = choose_provider(headers, provider, breakered: true) service.generate_526_pdf(form_json, transaction_id) end |
#get_meta_data(doc_type) ⇒ Object
Generate metadata for metadata.json file for the lighthouse benefits intake API to send along to Central Mail
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 190 def (doc_type) auth_info = submission.auth_headers = { 'veteranFirstName' => auth_info['va_eauth_firstName'], 'veteranLastName' => auth_info['va_eauth_lastName'], 'fileNumber' => auth_info['va_eauth_pnid'], 'zipCode' => zip, 'source' => 'va.gov backup submission', 'docType' => doc_type, 'businessLine' => 'CMP', 'claimDate' => submission.created_at.iso8601, 'forceOfframp' => 'true' } SimpleFormsApiSubmission::MetadataValidator.validate() end |
#get_uploads ⇒ Object
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 358 def get_uploads uploads = submission.form[FORM_526_UPLOADS] uploads.each do |upload| guid = upload['confirmationCode'] sea = SupportingEvidenceAttachment.find_by(guid:) file = sea&.get_file raise ArgumentError, "supporting evidence attachment with guid #{guid} has no file data" if file.nil? fname = File.basename(file.path) entropied_fname = "#{Common::FileHelpers.random_file_path}.#{Time.now.to_i}.#{fname}" File.binwrite(entropied_fname, file.read) docs << upload.merge!(file: entropied_fname, type: FORM_526_UPLOADS_DOC_TYPE, evssDocType: upload['attachmentId']) end end |
#instantiate_upload_info_from_lighthouse ⇒ Object
124 125 126 127 128 129 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 124 def instantiate_upload_info_from_lighthouse initial_upload = @lighthouse_service.get_location_and_uuid @initial_upload_uuid = initial_upload[:uuid] @initial_upload_location = initial_upload[:location] @initial_upload_fetched = true end |
#log_info(message:, upload_type:, uuid:) ⇒ Object
217 218 219 220 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 217 def log_info(message:, upload_type:, uuid:) ::Rails.logger.info({ message:, upload_type:, upload_uuid: uuid, submission_id: @submission.id }) end |
#log_resp(message:, resp:) ⇒ Object
222 223 224 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 222 def log_resp(message:, resp:) ::Rails.logger.info({ message:, response: resp, submission_id: @submission.id }) end |
#new_s3_resource ⇒ Object
- remediation effort
167 168 169 170 171 172 173 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 167 def new_s3_resource Aws::S3::Resource.new( region: Settings.form526_backup.aws.region, access_key_id: Settings.form526_backup.aws.access_key_id, secret_access_key: Settings.form526_backup.aws.secret_access_key ) end |
#process! ⇒ Object
86 87 88 89 90 91 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 86 def process! # Generates or makes calls to get, all PDFs, adds all to self.docs obj gather_docs! unless @docs_gathered # Take assemebled self.docs and aggregate and send how needed send_to_central_mail_through_lighthouse_claims_intake_api! end |
#received_date ⇒ Object
183 184 185 186 187 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 183 def received_date date = SavedClaim::DisabilityCompensation.find(submission.saved_claim_id).created_at date = date.in_time_zone('Central Time (US & Canada)') date.strftime('%Y-%m-%d %H:%M:%S') end |
#return_upload_params_and_docs(form526_doc, attachments) ⇒ Object
249 250 251 252 253 254 255 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 249 def return_upload_params_and_docs(form526_doc, ) lighthouse_service.get_upload_docs( file_with_full_path: form526_doc[:file], metadata: form526_doc[:metadata].to_json, attachments: ) end |
#s3_bucket ⇒ Object
- remediation effort
162 163 164 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 162 def s3_bucket Settings.form526_backup.aws.bucket end |
#send_to_central_mail_through_lighthouse_claims_intake_api! ⇒ Object
206 207 208 209 210 211 212 213 214 215 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 206 def send_to_central_mail_through_lighthouse_claims_intake_api! instantiate_upload_info_from_lighthouse unless @initial_upload_fetched initial_payload, other_payloads = evidence_526_split if SUB_METHOD == :single submit_as_one(initial_payload, other_payloads) else submit_initial_payload(initial_payload) submit_ancillary_payloads(other_payloads) end end |
#submit_ancillary_payloads(docs) ⇒ Object
292 293 294 295 296 297 298 299 300 301 302 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 292 def submit_ancillary_payloads(docs) docs.each do |doc| ul = get_upload_location_and_uuid log_info(message: 'Uploading ancillary fallback payload(s) to Lighthouse', upload_type: doc[:type], uuid: ul[:uuid]) lighthouse_service.upload_doc(upload_url: ul[:location], file: doc[:file], metadata: doc[:metadata].to_json) log_info(message: 'Uploading ancillary fallback payload(s) to Lighthouse Successful', upload_type: doc[:type], uuid: ul[:uuid]) end end |
#submit_as_one(initial_payload, other_payloads = nil, return_docs_instead_of_sending: false) ⇒ Object
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 257 def submit_as_one(initial_payload, other_payloads = nil, return_docs_instead_of_sending: false) seperated = initial_payload.group_by { |doc| doc[:type] } form526_doc = seperated[FORM_526_DOC_TYPE].first evidence_files = [] unless seperated[FORM_526_UPLOADS_DOC_TYPE].nil? evidence_files = seperated[FORM_526_UPLOADS_DOC_TYPE].map.with_index do |doc, i| { file: doc[:file], file_name: "evidence_#{i + 1}.pdf" } end end = (evidence_files, other_payloads) # Optional exit point to just return the docs/payloads, to be utilized by other classes if return_docs_instead_of_sending return_upload_params_and_docs(form526_doc, ) else submit_to_lh_claims_intake_api(form526_doc, ) end end |
#submit_initial_payload(initial_payload) ⇒ Object
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 275 def submit_initial_payload(initial_payload) seperated = initial_payload.group_by { |doc| doc[:type] } form526_doc = seperated[FORM_526_DOC_TYPE].first evidence_files = seperated[FORM_526_UPLOADS_DOC_TYPE].pluck(:file) log_info(message: 'Uploading initial fallback payload to Lighthouse', upload_type: FORM_526_DOC_TYPE, uuid: initial_upload_uuid) lighthouse_service.upload_doc( upload_url: initial_upload_location, file: form526_doc[:file], metadata: form526_doc[:metadata].to_json, attachments: evidence_files ) log_info(message: 'Uploading initial fallback payload to Lighthouse Successful', upload_type: FORM_526_DOC_TYPE, uuid: initial_upload_uuid) @submission.update!(backup_submitted_claim_id: initial_upload_uuid) end |
#submit_to_lh_claims_intake_api(form526_doc, attachments) ⇒ Object
235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 235 def submit_to_lh_claims_intake_api(form526_doc, ) log_info(message: 'Uploading single fallback payload to Lighthouse', upload_type: FORM_526_DOC_TYPE, uuid: initial_upload_uuid) lighthouse_service.upload_doc( upload_url: initial_upload_location, file: form526_doc[:file], metadata: form526_doc[:metadata].to_json, attachments: ) log_info(message: 'Uploading single fallback payload to Lighthouse Successful', upload_type: FORM_526_DOC_TYPE, uuid: initial_upload_uuid) @submission.update!(backup_submitted_claim_id: initial_upload_uuid) end |
#upload_location_to_location_and_uuid(upload_return) ⇒ Object
Transforms the lighthouse response to the only info we actually need from it
176 177 178 179 180 181 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 176 def upload_location_to_location_and_uuid(upload_return) { uuid: upload_return.dig('data', 'id'), location: upload_return.dig('data', 'attributes', 'location') } end |
#upload_pdf_submission_to_s3(return_url: false, url_life_length: 1.week.to_i) ⇒ Object
- remediation effort
-
This code is to take a 526 submission, generate the pdfs,
and upload to aws for manual review
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 108 def upload_pdf_submission_to_s3(return_url: false, url_life_length: 1.week.to_i) gather_docs! unless @docs_gathered i = 0 params_docs = docs.map do |doc| doc_type = doc[:evssDocType] || doc[:metadata][:docType] { file_path: BenefitsIntakeService::Service.get_file_path_from_objs(doc[:file]), docType: DOCTYPE_MAPPING[doc_type] || doc_type, file_name: DOCTYPE_NAMES.include?(doc_type) ? "#{doc_type}.pdf" : "attachment#{i += 1}.pdf" } end = (FORM_526_DOC_TYPE) zipname = "#{submission.id}.zip" generate_zip_and_upload(params_docs, zipname, , return_url, url_life_length) end |
#write_to_tmp_file(content, ext = 'pdf') ⇒ Object
319 320 321 322 323 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 319 def write_to_tmp_file(content, ext = 'pdf') fname = "#{Common::FileHelpers.random_file_path}.#{ext}" File.binwrite(fname, content) fname end |