Class: Webhook::WebhookResource

Inherits:
Object
  • Object
show all
Includes:
Request
Defined in:
lib/tremendous/webhook.rb

Instance Method Summary collapse

Methods included from Request

#_execute, #access_token, #delete, #get, #handle_response, #initialize, #post, #put, #uri, #url

Instance Method Details

#create!(url, data = {}) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/tremendous/webhook.rb', line 16

def create!(url, data={})
  post(
    'webhooks',
    body: {url: url}.merge(data).to_json,
    headers: { 'Content-Type' => 'application/json' }
  )[:webhook]
end

#delete!(id) ⇒ Object



32
33
34
# File 'lib/tremendous/webhook.rb', line 32

def delete!(id)
  delete("webhooks/#{id}")[:webhook]
end

#events(id) ⇒ Object



36
37
38
# File 'lib/tremendous/webhook.rb', line 36

def events(id)
  get("webhooks/#{id}/events")[:events]
end

#listObject



24
25
26
# File 'lib/tremendous/webhook.rb', line 24

def list
  get("webhooks")[:webhooks]
end

#show(id) ⇒ Object



28
29
30
# File 'lib/tremendous/webhook.rb', line 28

def show(id)
  get("webhooks/#{id}")[:webhook]
end

#simulate!(id, event, data = {}) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/tremendous/webhook.rb', line 40

def simulate!(id, event, data={})
  post(
    "webhooks/#{id}/simulate",
    body: {event: event}.merge(data).to_json,
    headers: { 'Content-Type' => 'application/json' }
  )
end