Class: AchClient::Logging::SavonObserver

Inherits:
Object
  • Object
show all
Defined in:
lib/ach_client/logging/savon_observer.rb

Overview

Hooks into every savon request. #notify is called before the request is made

Instance Method Summary collapse

Instance Method Details

#notify(operation_name, builder, globals, _locals) ⇒ NilClass

Hooks into every SOAP request and sends the XML body to be logged.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ach_client/logging/savon_observer.rb', line 14

def notify(operation_name, builder, globals, _locals)
  # Since Savon only lets us register observers globally this method is called by any other Savon clients outside
  #   this library. We don't want to log for those other clients so we check to see that the request came from
  #   AchClient by comparing the wsdl to our known wsdls
  return unless [
    AchClient::ICheckGateway.wsdl,
    AchClient::AchWorks.wsdl
  ].include?(globals.instance_variable_get(:@options)[:wsdl])
  # Send the xml body to the logger job
  AchClient::Logging::LogProviderJob.perform_async(
    body: builder.to_s,
    name: "request-#{operation_name}-#{DateTime.now}.xml"
  )

  # Must return nil so the request is unaltered
  nil
end