Class: DecisionReviewV1::Processor::Form4142Processor
- Inherits:
-
Object
- Object
- DecisionReviewV1::Processor::Form4142Processor
- Defined in:
- lib/decision_review_v1/utilities/form_4142_processor.rb
Constant Summary collapse
- SIGNATURE_DATE_KEY =
'signatureDate'
- SIGNATURE_TIMESTAMP_FORMAT =
'%Y-%m-%d %H:%M:%S'
- TIMEZONE =
'Central Time (US & Canada)'
Instance Attribute Summary collapse
-
#pdf_path ⇒ Pathname
readonly
The generated PDF path.
-
#request_body ⇒ Hash
readonly
The generated request body.
Instance Method Summary collapse
- #generate_metadata ⇒ Object private
- #generate_stamp_pdf ⇒ Object
-
#initialize(form_data:, submission_id: nil) ⇒ Form4142Processor
constructor
A new instance of Form4142Processor.
- #received_date ⇒ Object private
- #set_signature_date(incoming_data) ⇒ Object private
- #submission_date ⇒ Object private
- #to_faraday_upload ⇒ Object private
Constructor Details
#initialize(form_data:, submission_id: nil) ⇒ Form4142Processor
Returns a new instance of Form4142Processor.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/decision_review_v1/utilities/form_4142_processor.rb', line 20 def initialize(form_data:, submission_id: nil) @submission = Form526Submission.find_by(id: submission_id) @form = set_signature_date(form_data) @pdf_path = generate_stamp_pdf @uuid = SecureRandom.uuid @request_body = { 'document' => to_faraday_upload, 'metadata' => } end |
Instance Attribute Details
#pdf_path ⇒ Pathname (readonly)
Returns the generated PDF path.
15 16 17 |
# File 'lib/decision_review_v1/utilities/form_4142_processor.rb', line 15 def pdf_path @pdf_path end |
#request_body ⇒ Hash (readonly)
Returns the generated request body.
18 19 20 |
# File 'lib/decision_review_v1/utilities/form_4142_processor.rb', line 18 def request_body @request_body end |
Instance Method Details
#generate_metadata ⇒ Object (private)
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/decision_review_v1/utilities/form_4142_processor.rb', line 54 def address = @form['veteranAddress'] country_is_us = address['country'] == 'US' veteran_full_name = @form['veteranFullName'] = { 'veteranFirstName' => veteran_full_name['first'], 'veteranLastName' => veteran_full_name['last'], 'fileNumber' => @form['vaFileNumber'] || @form['veteranSocialSecurityNumber'], 'receiveDt' => received_date, # 'uuid' => "#{@uuid}_4142", # was trying to include the main claim uuid here and just append 4142 # but central mail portal does not support that 'uuid' => @uuid, 'zipCode' => address['postalCode'], 'source' => 'VA Forms Group B', 'hashV' => Digest::SHA256.file(@pdf_path).hexdigest, 'numberAttachments' => 0, 'docType' => FORM_ID, 'numberPages' => PDF::Reader.new(@pdf_path).pages.size } SimpleFormsApiSubmission::MetadataValidator.validate( , zip_code_is_us_based: country_is_us ).to_json end |
#generate_stamp_pdf ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/decision_review_v1/utilities/form_4142_processor.rb', line 31 def generate_stamp_pdf pdf = PdfFill::Filler.fill_ancillary_form( @form, @uuid, FORM_ID ) stamped_path = PDFUtilities::DatestampPdf.new(pdf).run(text: 'VA.gov', x: 5, y: 5, timestamp: submission_date) PDFUtilities::DatestampPdf.new(stamped_path).run( text: 'VA.gov Submission', x: 510, y: 775, text_only: true ) end |
#received_date ⇒ Object (private)
87 88 89 |
# File 'lib/decision_review_v1/utilities/form_4142_processor.rb', line 87 def received_date submission_date.strftime(SIGNATURE_TIMESTAMP_FORMAT) end |
#set_signature_date(incoming_data) ⇒ Object (private)
91 92 93 |
# File 'lib/decision_review_v1/utilities/form_4142_processor.rb', line 91 def set_signature_date(incoming_data) incoming_data.merge({ SIGNATURE_DATE_KEY => received_date }) end |
#submission_date ⇒ Object (private)
79 80 81 82 83 84 85 |
# File 'lib/decision_review_v1/utilities/form_4142_processor.rb', line 79 def submission_date if @submission.nil? Time.now.in_time_zone(TIMEZONE) else @submission.created_at.in_time_zone(TIMEZONE) end end |
#to_faraday_upload ⇒ Object (private)
47 48 49 50 51 52 |
# File 'lib/decision_review_v1/utilities/form_4142_processor.rb', line 47 def to_faraday_upload Faraday::UploadIO.new( @pdf_path, Mime[:pdf].to_s ) end |