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
- #gather_docs! ⇒ 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.
- #process! ⇒ Object
-
#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.
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
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 67 def initialize(submission_id, docs = [], get_upload_location_on_instantiation: true, ignore_expiration: false) @submission_id = submission_id @submission = Form526Submission.find(submission_id) @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.
24 25 26 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 24 def docs @docs end |
#docs_gathered ⇒ Object (readonly)
Returns the value of attribute docs_gathered.
21 22 23 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 21 def docs_gathered @docs_gathered end |
#ignore_expiration ⇒ Object (readonly)
Returns the value of attribute ignore_expiration.
21 22 23 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 21 def ignore_expiration @ignore_expiration end |
#initial_upload ⇒ Object (readonly)
Returns the value of attribute initial_upload.
21 22 23 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 21 def initial_upload @initial_upload end |
#initial_upload_fetched ⇒ Object (readonly)
Returns the value of attribute initial_upload_fetched.
21 22 23 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 21 def initial_upload_fetched @initial_upload_fetched end |
#initial_upload_location ⇒ Object (readonly)
Returns the value of attribute initial_upload_location.
21 22 23 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 21 def initial_upload_location @initial_upload_location end |
#initial_upload_uuid ⇒ Object (readonly)
Returns the value of attribute initial_upload_uuid.
21 22 23 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 21 def initial_upload_uuid @initial_upload_uuid end |
#lighthouse_service ⇒ Object (readonly)
Returns the value of attribute lighthouse_service.
21 22 23 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 21 def lighthouse_service @lighthouse_service end |
#submission ⇒ Object (readonly)
Returns the value of attribute submission.
21 22 23 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 21 def submission @submission end |
#submission_id ⇒ Object (readonly)
Returns the value of attribute submission_id.
21 22 23 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 21 def submission_id @submission_id end |
#zip ⇒ Object (readonly)
Returns the value of attribute zip.
21 22 23 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 21 def zip @zip end |
Instance Method Details
#gather_docs! ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 90 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 |
#process! ⇒ Object
83 84 85 86 87 88 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 83 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 |
#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
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/sidekiq/form526_backup_submission_process/processor.rb', line 105 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 |