Class: Preneeds::Service

Inherits:
Common::Client::Base show all
Includes:
Common::Client::Concerns::Monitoring
Defined in:
lib/preneeds/service.rb

Overview

Proxy Service for the EOAS (Eligibility Office Automation System) Service’s PreNeed Applications endpoints. Requests are SOAP format, and the request bodies are built using the ‘Savon` gem, The `Mail` gem is used to generate attachments for the #receive_pre_need_application method. The actual submission of requests is facilitated using methods defined in the Common::Client::Base parent class.

Constant Summary collapse

STATSD_KEY_PREFIX =

Prefix string for StatsD monitoring

'api.preneeds'
STARTING_CID =

Used in building SOAP request

'<soap-request-body@soap>'

Instance Method Summary collapse

Methods included from Common::Client::Concerns::Monitoring

#with_monitoring

Methods inherited from Common::Client::Base

configuration, #raise_backend_exception

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger

Instance Method Details

#get_cemeteriesCommon::Collection<Preneeds::Cemetery>

POST to retrieve military cemeteries

Returns:



27
28
29
30
31
32
# File 'lib/preneeds/service.rb', line 27

def get_cemeteries
  soap = savon_client.build_request(:get_cemeteries, message: {})
  json = with_monitoring { perform(:post, '', soap.body).body }

  Common::Collection.new(Cemetery, **json)
end

#receive_pre_need_application(burial_form) ⇒ Preneeds::ReceiveApplication

POST to submit a BurialForm

Parameters:

Returns:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/preneeds/service.rb', line 39

def receive_pre_need_application(burial_form)
  tracking_number = burial_form.tracking_number
  soap = savon_client.build_request(
    :receive_pre_need_application,
    message: {
      pre_need_request: burial_form.as_eoas
    }
  )

  body_and_headers = build_body_and_headers(soap, burial_form)

  json = with_monitoring { perform(:post, '', body_and_headers[:body], body_and_headers[:headers]).body }
  Raven.extra_context(response: json)

  json = json[:data].merge('tracking_number' => tracking_number)

  ReceiveApplication.new(json)
end