Class: Jbr::Event

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

Constant Summary collapse

SIGNATURE_HEADER =
'X-Jobber-Hmac-SHA256'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Event

Returns a new instance of Event.

Parameters:

  • params (Hash) (defaults to: {})

    the payload for an event webhook.



7
8
9
# File 'lib/jbr/event.rb', line 7

def initialize(params = {})
  @params = params
end

Class Method Details

.params_for(item_id:, account_id:) ⇒ Hash

Returns the shape of the payload send by Jobber to the callback URL.

Returns:

  • (Hash)

    the shape of the payload send by Jobber to the callback URL.



18
19
20
# File 'lib/jbr/event.rb', line 18

def self.params_for(item_id:, account_id:)
  { data: { webHookEvent: { itemId: item_id, accountId:  } } }
end

Instance Method Details

#account_idString

Returns unique identifier of the event account.

Returns:

  • (String)

    unique identifier of the event account.



15
# File 'lib/jbr/event.rb', line 15

def  = @params.dig :data, :webHookEvent, :accountId

#item_idString

Returns unique identifier of the event target.

Returns:

  • (String)

    unique identifier of the event target.



12
# File 'lib/jbr/event.rb', line 12

def item_id = @params.dig :data, :webHookEvent, :itemId