Class: EVSS::Dependents::Service
- Inherits:
-
Service
- Object
- Common::Client::Base
- Service
- EVSS::Dependents::Service
- Defined in:
- lib/evss/dependents/service.rb
Overview
Proxy Service for Dependents Caseflow.
Constant Summary collapse
- STATSD_KEY_PREFIX =
'api.evss.dependents'
Instance Attribute Summary
Attributes inherited from Service
Instance Method Summary collapse
- #change_evss_times!(object) ⇒ Object private
-
#clean_form(form) ⇒ Object
Cleans in-flight form using form hash.
- #convert_evss_time(time) ⇒ Object private
-
#retrieve ⇒ Faraday::Response
Fetches user info from the retrieve endpoint.
-
#save(form) ⇒ Object
Saves in-flight form using form hash.
-
#submit(form, form_id) ⇒ Hash
Submits 686 form with form ID.
-
#validate(form) ⇒ Object
Validates in-flight form using form hash.
Methods inherited from Service
#handle_error, #headers, #initialize, #perform, #save_error_details, service_is_up?, #with_monitoring_and_error_handling
Methods included from Common::Client::Concerns::Monitoring
#increment, #increment_failure, #increment_total, #with_monitoring
Methods inherited from Common::Client::Base
#config, configuration, #connection, #delete, #get, #perform, #post, #put, #raise_backend_exception, #raise_not_authenticated, #request, #sanitize_headers!, #service_name
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
Constructor Details
This class inherits a constructor from EVSS::Service
Instance Method Details
#change_evss_times!(object) ⇒ Object (private)
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/evss/dependents/service.rb', line 89 def change_evss_times!(object) case object when Hash object.each do |k, v| if k.downcase.include?('date') && v.is_a?(Numeric) object[k] = convert_evss_time(v) else change_evss_times!(v) end end when Array object.each do |item| change_evss_times!(item) end end end |
#clean_form(form) ⇒ Object
Cleans in-flight form using form hash.
36 37 38 39 40 |
# File 'lib/evss/dependents/service.rb', line 36 def clean_form(form) with_monitoring_and_error_handling do perform(:post, 'inflightform/cleanForm', form.to_json, headers).body end end |
#convert_evss_time(time) ⇒ Object (private)
106 107 108 |
# File 'lib/evss/dependents/service.rb', line 106 def convert_evss_time(time) Time.strptime(time.to_s, '%Q').utc.iso8601 end |
#retrieve ⇒ Faraday::Response
Fetches user info from the retrieve endpoint.
24 25 26 27 28 |
# File 'lib/evss/dependents/service.rb', line 24 def retrieve with_monitoring_and_error_handling do perform(:get, 'load/retrieve') end end |
#save(form) ⇒ Object
Saves in-flight form using form hash.
60 61 62 63 64 |
# File 'lib/evss/dependents/service.rb', line 60 def save(form) with_monitoring_and_error_handling do perform(:post, 'inflightform/saveForm', form.to_json, headers).body end end |
#submit(form, form_id) ⇒ Hash
Submits 686 form with form ID
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/evss/dependents/service.rb', line 73 def submit(form, form_id) form['submitProcess']['application']['draftFormId'] = form_id change_evss_times!(form) with_monitoring_and_error_handling do res = perform( :post, 'form686submission/submit', form.to_xml(root: 'submit686Request'), 'Content-Type' => 'application/xml' ) Hash.from_xml(res.body) end end |
#validate(form) ⇒ Object
Validates in-flight form using form hash.
48 49 50 51 52 |
# File 'lib/evss/dependents/service.rb', line 48 def validate(form) with_monitoring_and_error_handling do perform(:post, 'inflightform/validateForm', form.to_json, headers).body end end |