Class: BugherdClient::Resources::V2::Webhook

Inherits:
Base
  • Object
show all
Defined in:
lib/bugherd_client/resources/v2/webhook.rb

Constant Summary collapse

EVENTS =
['task_create', 'task_update', 'task_destroy', 'comment']

Constants inherited from Base

Base::DEFAULT_HEADER_ATTRS

Instance Attribute Summary

Attributes inherited from Base

#connection, #options

Instance Method Summary collapse

Methods inherited from Base

#api_methods, #converter, #initialize, #parse_response, #send_request

Constructor Details

This class inherits a constructor from BugherdClient::Resources::V2::Base

Instance Method Details

#allObject

LIST

Get a list of currently installed webhooks.

GET /api_v2/webhooks.json



16
17
18
19
# File 'lib/bugherd_client/resources/v2/webhook.rb', line 16

def all
  raw_response = get_request('webhooks')
  parse_response(raw_response, :webhooks)
end

#create(payload = {}) ⇒ Object

CREATE

When installing a webhook, specify an event you wish to hook into. Choose from: ‘task_create’, ‘task_update’, ‘comment’ or ‘task_destroy’. To get activity for all 3 events, create an entry for each event.

‘project_id’ is optional; it only needs to be specified if you’d only like events on a specific project. Omitting ‘project_id’ results in notifications of activity on all your projects.

PARAMS

'project_id':1,
'target_url':'https://app.example.com/api/bugherd_sync/project/1/task_create',
'event':'task_create'



38
39
40
41
# File 'lib/bugherd_client/resources/v2/webhook.rb', line 38

def create(payload = {})
  raw_response = post_request('webhooks', payload)
  parse_response(raw_response, :webhook)
end

#delete(webhook_id) ⇒ Object

DELETE

DELETE /api_v2/webhooks/#id.json



46
47
48
49
# File 'lib/bugherd_client/resources/v2/webhook.rb', line 46

def delete(webhook_id)
  raw_response = delete_request("webhooks/#{webhook_id}")
  parse_response(raw_response)
end

#eventsObject



7
8
9
# File 'lib/bugherd_client/resources/v2/webhook.rb', line 7

def events
  self.class::EVENTS
end