Class: Dropbox::Sign::EventCallbackHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/dropbox-sign/event_callback_helper.rb

Constant Summary collapse

EVENT_TYPE_ACCOUNT_CALLBACK =
"account_callback"
EVENT_TYPE_APP_CALLBACK =
"app_callback"

Class Method Summary collapse

Class Method Details

.get_callback_type(event_callback) ⇒ Object

Identifies the callback type, one of “account_callback” or “app_callback”. “app_callback” will always include a value for “reported_for_app_id”

Parameters:

Returns:

  • string



44
45
46
47
48
49
50
51
52
# File 'lib/dropbox-sign/event_callback_helper.rb', line 44

def self.get_callback_type(event_callback)
   = event_callback.event. || EventCallbackRequestEventMetadata.new

  if .reported_for_app_id.nil? || .reported_for_app_id.empty?
    return EVENT_TYPE_ACCOUNT_CALLBACK
  end

  return EVENT_TYPE_APP_CALLBACK
end

.is_valid(api_key, event_callback) ⇒ Object

Verify that a callback came from HelloSign.com

Parameters:

Returns:

  • bool



29
30
31
32
33
34
35
36
37
# File 'lib/dropbox-sign/event_callback_helper.rb', line 29

def self.is_valid(api_key, event_callback)
  hash = OpenSSL::HMAC.hexdigest(
    "SHA256",
    api_key,
    "#{event_callback.event.event_time}#{event_callback.event.event_type}",
  )

  return event_callback.event.event_hash === hash
end