Module: VA1010Forms::Utils
- Includes:
- ActionView::Helpers::NumberHelper
- Included in:
- Form1010Ezr::Service, HCA::Service, HealthCareApplication
- Defined in:
- lib/va1010_forms/utils.rb
Instance Method Summary collapse
- #es_submit(parsed_form, user_identifier, form_id) ⇒ Object
- #log_payload_info(formatted_form, submission_body) ⇒ Object private
- #override_parsed_form(parsed_form) ⇒ Object
- #soap ⇒ Object
- #submission_body(formatted_form) ⇒ Object private
Instance Method Details
#es_submit(parsed_form, user_identifier, form_id) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/va1010_forms/utils.rb', line 10 def es_submit(parsed_form, user_identifier, form_id) formatted = HCA::EnrollmentSystem.veteran_to_save_submit_form(parsed_form, user_identifier, form_id) submission_body = submission_body(formatted) response = perform(:post, '', submission_body) root = response.body.locate('S:Envelope/S:Body/submitFormResponse').first form_submission_id = root.locate('formSubmissionId').first.text.to_i { success: true, formSubmissionId: form_submission_id, timestamp: root.locate('timeStamp').first&.text || Time.now.getlocal.to_s } end |
#log_payload_info(formatted_form, submission_body) ⇒ Object (private)
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/va1010_forms/utils.rb', line 53 def log_payload_info(formatted_form, submission_body) form_name = formatted_form.dig('va:form', 'va:formIdentifier', 'va:value') = formatted_form.dig('va:form', 'va:attachments') = &.length || 0 # Log the attachment sizes in descending order if .positive? # Convert the attachments into xml format so they resemble what will be sent to VES = .map { |a| a.to_xml.size }.sort.reverse!.map { |size| number_to_human_size(size) }.join(', ') Rails.logger.info("Attachment sizes in descending order: #{}") end Rails.logger.info("Payload for submitted #{form_name}: " \ "Body size of #{number_to_human_size(submission_body.bytesize)} " \ "with #{} attachment(s)") end |
#override_parsed_form(parsed_form) ⇒ Object
39 40 41 |
# File 'lib/va1010_forms/utils.rb', line 39 def override_parsed_form(parsed_form) HCA::OverridesParser.new(parsed_form).override end |
#soap ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/va1010_forms/utils.rb', line 25 def soap # Savon *seems* like it should be setting these things correctly # from what the docs say. Our WSDL file is weird, maybe? Savon.client( wsdl: HCA::Configuration::WSDL, env_namespace: :soap, element_form_default: :qualified, namespaces: { 'xmlns:tns': 'http://va.gov/service/esr/voa/v1' }, namespace: 'http://va.gov/schema/esr/voa/v1' ) end |
#submission_body(formatted_form) ⇒ Object (private)
45 46 47 48 49 50 51 |
# File 'lib/va1010_forms/utils.rb', line 45 def submission_body(formatted_form) content = Gyoku.xml(formatted_form) submission_body = soap.build_request(:save_submit_form, message: content).body log_payload_info(formatted_form, submission_body) submission_body end |