Class: Trello::Webhook
Overview
A webhook is an url called each time a specified idModel is updated
Instance Attribute Summary
Attributes inherited from BasicData
Class Method Summary collapse
-
.create(options) ⇒ Object
Create a new webhook and save it on Trello.
-
.find(id, params = {}) ⇒ Object
Find a specific webhook by its id.
Instance Method Summary collapse
-
#activated? ⇒ Boolean
Check if the webhook is activated.
-
#delete ⇒ Object
Delete this webhook.
- #save ⇒ Object
- #update! ⇒ Object
- #update_fields(fields) ⇒ Object
Methods inherited from BasicData
#==, client, #initialize, many, one, parse, parse_many, path_name, #refresh!, register_attributes, save
Constructor Details
This class inherits a constructor from Trello::BasicData
Class Method Details
.create(options) ⇒ Object
Create a new webhook and save it on Trello.
16 17 18 19 20 21 |
# File 'lib/trello/webhook.rb', line 16 def create() client.create(:webhook, 'description' => [:description], 'idModel' => [:id_model], 'callbackURL' => [:callback_url]) end |
.find(id, params = {}) ⇒ Object
Find a specific webhook by its id.
11 12 13 |
# File 'lib/trello/webhook.rb', line 11 def find(id, params = {}) client.find(:webhook, id, params) end |
Instance Method Details
#activated? ⇒ Boolean
Check if the webhook is activated
59 60 61 |
# File 'lib/trello/webhook.rb', line 59 def activated? active end |
#delete ⇒ Object
Delete this webhook
54 55 56 |
# File 'lib/trello/webhook.rb', line 54 def delete client.delete("/webhooks/#{id}") end |
#save ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/trello/webhook.rb', line 33 def save # If we have an id, just update our fields. return update! if id client.post("/webhooks", { :description => description, :idModel => id_model, :callbackURL => callback_url }).json_into(self) end |
#update! ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/trello/webhook.rb', line 44 def update! client.put("/webhooks/#{id}", { :description => description, :idModel => id_model, :callbackURL => callback_url, :active => active }) end |
#update_fields(fields) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/trello/webhook.rb', line 24 def update_fields(fields) attributes[:id] = fields['id'] attributes[:description] = fields['description'] attributes[:id_model] = fields['idModel'] attributes[:callback_url] = fields['callbackURL'] attributes[:active] = fields['active'] self end |