class Trello::Webhook
A webhook is a URL called each time a specified model is updated
@!attribute [r] id
@return [String]
@!attribute [r] description
@return [String]
@!attribute [r] id_model
@return [String] A 24-character hex string
@!attribute [r] callback_url
@return [String]
@!attribute [r] active
@return [Boolean]
Public Class Methods
Create a new webhook and save it to Trello
.
@param [Hash] options
@option options [String] :description (optional) A string with a length from 0 to 16384 @option options [String] :callback_url (required) A valid URL that is
reachable with a HEAD request
@option options [String] :id_model (required) id of the model that should be hooked
@raise [Trello::Error] if the Webhook
could not be created.
@return [Trello::Webhook]
# File lib/trello/webhook.rb, line 41 def create(options) client.create(:webhook, 'description' => options[:description], 'idModel' => options[:id_model], 'callbackURL' => options[:callback_url]) end
Public Instance Methods
Check if the webhook is activated
@return [Boolean]
# File lib/trello/webhook.rb, line 99 def activated? active end
Delete this webhook
@return [String] the JSON response from the Trello
API
# File lib/trello/webhook.rb, line 92 def delete client.delete("/webhooks/#{id}") end
Save the webhook.
@raise [Trello::Error] if the Webhook
could not be saved.
@return [String] the JSON representation of the saved webhook.
# File lib/trello/webhook.rb, line 64 def save # If we have an id, just update our fields. return update! if id from_response client.post("/webhooks", { description: description, idModel: id_model, callbackURL: callback_url }) end
Update the webhook.
@raise [Trello::Error] if the Webhook
could not be saved.
@return [String] the JSON representation of the updated webhook.
# File lib/trello/webhook.rb, line 80 def update! client.put("/webhooks/#{id}", { description: description, idModel: id_model, callbackURL: callback_url, active: active }) end
@return [Trello::Webhook] self
# File lib/trello/webhook.rb, line 50 def update_fields(fields) attributes[:id] = fields['id'] attributes[:description] = fields['description'] || fields[:description] attributes[:id_model] = fields['idModel'] || fields[:id_model] attributes[:callback_url] = fields['callbackURL'] || fields[:callback_url] attributes[:active] = fields['active'] self end