Module: KlaviyoAPI::Connection::RequestNotification

Included in:
ActiveResource::Connection, KlaviyoAPI::Connection
Defined in:
lib/klaviyo_api/connection.rb

Instance Method Summary collapse

Instance Method Details

#notify_about_request(response, arguments) ⇒ Object



26
27
28
29
30
31
# File 'lib/klaviyo_api/connection.rb', line 26

def notify_about_request(response, arguments)
  ActiveSupport::Notifications.instrument('request.active_resource_detailed') do |payload|
    payload[:response] = response
    payload[:data]     = arguments
  end
end

#request(method, path, *arguments) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/klaviyo_api/connection.rb', line 16

def request(method, path, *arguments)
  super.tap do |response|
    notify_about_request response, arguments
  end
rescue => e
  notify_about_request e.response, arguments if e.respond_to? :response

  raise
end