Class: Jbr::Event

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

Overview

One webhook Jobber posted, and the signature header it arrives under.

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.



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

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

Class Method Details

.params_for(item_id:, account_id:) ⇒ Hash

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

Returns:

  • (Hash)

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



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

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.



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

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

#item_idString

Returns unique identifier of the event target.

Returns:

  • (String)

    unique identifier of the event target.



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

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