Class: Integromat::Webhook

Inherits:
Base
  • Object
show all
Defined in:
lib/integromat/webhook.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#api, #api_url, #config, #hook_path, #post_hook, #web_hook_id

Constructor Details

#initialize(hook_ref, hook_id = nil) ⇒ Webhook

Returns a new instance of Webhook.



5
6
7
8
9
10
11
# File 'lib/integromat/webhook.rb', line 5

def initialize(hook_ref, hook_id = nil)
  super()

  self.hook_ref = hook_ref

  @web_hook_id = hook_id if hook_id
end

Instance Attribute Details

#hook_refObject

Returns the value of attribute hook_ref.



3
4
5
# File 'lib/integromat/webhook.rb', line 3

def hook_ref
  @hook_ref
end

Instance Method Details

#trigger(data = {}) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/integromat/webhook.rb', line 13

def trigger(data = {})
  unless web_hook_id
    raise IntegromatMisConfiguration, "No hook configured for #{hook_ref}. Configured hooks: #{config.web_hooks}"
  end

  post_hook(data)
end