Class: EVSS::Dependents::Service

Inherits:
Service show all
Defined in:
lib/evss/dependents/service.rb

Overview

Proxy Service for Dependents Caseflow.

Examples:

Create a service and submitting a 686 form

dependents_response = Dependents::Service.new.submit(form, form_id)

Constant Summary collapse

STATSD_KEY_PREFIX =
'api.evss.dependents'

Instance Attribute Summary

Attributes inherited from Service

#transaction_id

Instance Method Summary collapse

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.

Parameters:

  • form (Hash)

    The form data.

Returns:

  • (Object)

    Faraday response body.



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

#retrieveFaraday::Response

Fetches user info from the retrieve endpoint.

Returns:

  • (Faraday::Response)

    Faraday response instance.



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.

Parameters:

  • form (Hash)

    The form data.

Returns:

  • (Object)

    Faraday response body.



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

Parameters:

  • form (Hash)

    The form data.

  • form_id (String)

    The form ID to be added to the form hash.

Returns:

  • (Hash)

    The response body in hash form.



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.

Parameters:

  • form (Hash)

    The form data.

Returns:

  • (Object)

    Faraday response body.



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