Class: Simplify::Event

Inherits:
Hash
  • Object
show all
Defined in:
lib/simplify/event.rb

Overview

An Event object

Class Method Summary collapse

Class Method Details

.create(params, public_key = nil, private_key = nil) ⇒ Object

Creates a webhook Event object

params

a hash of parameters; valid keys are:

  • payload The raw JWS message payload. required

  • url The URL for the webhook. If present it must match the URL registered for the webhook.

public_key

Public to use for the API call. If nil, the value of Simplify::public_key will be used.

private_key

API key to use for the API call. If nil, the value of Simplify::private_key will be used.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/simplify/event.rb', line 43

def self.create(params, public_key = nil, private_key = nil)

    if public_key == nil then
        public_key = Simplify::public_key
    end
    if private_key == nil then
        private_key = Simplify::private_key
    end

   h = Simplify::PaymentsApi.jws_decode(params, public_key, private_key)

 if !h['event']
     raise ApiException.new("Incorrect data in webhook event", nil, nil)
 end

 obj = Event.new()
 obj = obj.merge(h['event'])

 obj
end