Class: Tremendous::Webhook::WebhookResource

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

Instance Attribute Summary

Attributes included from Request

#access_token, #uri

Instance Method Summary collapse

Methods included from Request

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

Instance Method Details

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



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

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

#delete!(id) ⇒ Object



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

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

#events(id) ⇒ Object



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

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

#listObject



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

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

#show(id) ⇒ Object



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

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

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



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

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