Class: Trello::Webhook
Overview
A webhook is a URL called each time a specified model is updated
Instance Attribute Summary collapse
- #active ⇒ Boolean readonly
- #callback_url ⇒ String readonly
- #description ⇒ String readonly
- #id ⇒ String readonly
-
#id_model ⇒ String
readonly
A 24-character hex string.
Attributes inherited from BasicData
Class Method Summary collapse
-
.create(options) ⇒ Trello::Webhook
Create a new webhook and save it to Trello.
-
.find(id, params = {}) ⇒ Trello::Webhook
Find a specific webhook by its ID.
Instance Method Summary collapse
-
#activated? ⇒ Boolean
Check if the webhook is activated.
-
#delete ⇒ String
Delete this webhook.
-
#save ⇒ String
Save the webhook.
-
#update! ⇒ String
Update the webhook.
-
#update_fields(fields) ⇒ Trello::Webhook
Self.
Methods inherited from BasicData
#==, client, #initialize, many, one, parse, parse_many, path_name, #refresh!, register_attributes, save
Methods included from JsonUtils
Constructor Details
This class inherits a constructor from Trello::BasicData
Instance Attribute Details
#active ⇒ Boolean (readonly)
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/trello/webhook.rb', line 14 class Webhook < BasicData register_attributes :id, :description, :id_model, :callback_url, :active, readonly: [ :id ] validates_presence_of :id, :id_model, :callback_url validates_length_of :description, in: 1..16384 class << self # Find a specific webhook by its ID. # # @raise [Trello::Error] if a Webhook with the given ID can't be found. # @return [Trello::Webhook] the Webhook with the given ID. def find(id, params = {}) client.find(:webhook, id, params) end # 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] def create() client.create(:webhook, 'description' => [:description], 'idModel' => [:id_model], 'callbackURL' => [:callback_url]) end end # @return [Trello::Webhook] self 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 # Save the webhook. # # @raise [Trello::Error] if the Webhook could not be saved. # # @return [String] the JSON representation of the saved webhook. 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. def update! client.put("/webhooks/#{id}", { description: description, idModel: id_model, callbackURL: callback_url, active: active }) end # Delete this webhook # # @return [String] the JSON response from the Trello API def delete client.delete("/webhooks/#{id}") end # Check if the webhook is activated # # @return [Boolean] def activated? active end end |
#callback_url ⇒ String (readonly)
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/trello/webhook.rb', line 14 class Webhook < BasicData register_attributes :id, :description, :id_model, :callback_url, :active, readonly: [ :id ] validates_presence_of :id, :id_model, :callback_url validates_length_of :description, in: 1..16384 class << self # Find a specific webhook by its ID. # # @raise [Trello::Error] if a Webhook with the given ID can't be found. # @return [Trello::Webhook] the Webhook with the given ID. def find(id, params = {}) client.find(:webhook, id, params) end # 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] def create() client.create(:webhook, 'description' => [:description], 'idModel' => [:id_model], 'callbackURL' => [:callback_url]) end end # @return [Trello::Webhook] self 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 # Save the webhook. # # @raise [Trello::Error] if the Webhook could not be saved. # # @return [String] the JSON representation of the saved webhook. 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. def update! client.put("/webhooks/#{id}", { description: description, idModel: id_model, callbackURL: callback_url, active: active }) end # Delete this webhook # # @return [String] the JSON response from the Trello API def delete client.delete("/webhooks/#{id}") end # Check if the webhook is activated # # @return [Boolean] def activated? active end end |
#description ⇒ String (readonly)
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/trello/webhook.rb', line 14 class Webhook < BasicData register_attributes :id, :description, :id_model, :callback_url, :active, readonly: [ :id ] validates_presence_of :id, :id_model, :callback_url validates_length_of :description, in: 1..16384 class << self # Find a specific webhook by its ID. # # @raise [Trello::Error] if a Webhook with the given ID can't be found. # @return [Trello::Webhook] the Webhook with the given ID. def find(id, params = {}) client.find(:webhook, id, params) end # 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] def create() client.create(:webhook, 'description' => [:description], 'idModel' => [:id_model], 'callbackURL' => [:callback_url]) end end # @return [Trello::Webhook] self 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 # Save the webhook. # # @raise [Trello::Error] if the Webhook could not be saved. # # @return [String] the JSON representation of the saved webhook. 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. def update! client.put("/webhooks/#{id}", { description: description, idModel: id_model, callbackURL: callback_url, active: active }) end # Delete this webhook # # @return [String] the JSON response from the Trello API def delete client.delete("/webhooks/#{id}") end # Check if the webhook is activated # # @return [Boolean] def activated? active end end |
#id ⇒ String (readonly)
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/trello/webhook.rb', line 14 class Webhook < BasicData register_attributes :id, :description, :id_model, :callback_url, :active, readonly: [ :id ] validates_presence_of :id, :id_model, :callback_url validates_length_of :description, in: 1..16384 class << self # Find a specific webhook by its ID. # # @raise [Trello::Error] if a Webhook with the given ID can't be found. # @return [Trello::Webhook] the Webhook with the given ID. def find(id, params = {}) client.find(:webhook, id, params) end # 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] def create() client.create(:webhook, 'description' => [:description], 'idModel' => [:id_model], 'callbackURL' => [:callback_url]) end end # @return [Trello::Webhook] self 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 # Save the webhook. # # @raise [Trello::Error] if the Webhook could not be saved. # # @return [String] the JSON representation of the saved webhook. 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. def update! client.put("/webhooks/#{id}", { description: description, idModel: id_model, callbackURL: callback_url, active: active }) end # Delete this webhook # # @return [String] the JSON response from the Trello API def delete client.delete("/webhooks/#{id}") end # Check if the webhook is activated # # @return [Boolean] def activated? active end end |
#id_model ⇒ String (readonly)
Returns A 24-character hex string.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/trello/webhook.rb', line 14 class Webhook < BasicData register_attributes :id, :description, :id_model, :callback_url, :active, readonly: [ :id ] validates_presence_of :id, :id_model, :callback_url validates_length_of :description, in: 1..16384 class << self # Find a specific webhook by its ID. # # @raise [Trello::Error] if a Webhook with the given ID can't be found. # @return [Trello::Webhook] the Webhook with the given ID. def find(id, params = {}) client.find(:webhook, id, params) end # 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] def create() client.create(:webhook, 'description' => [:description], 'idModel' => [:id_model], 'callbackURL' => [:callback_url]) end end # @return [Trello::Webhook] self 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 # Save the webhook. # # @raise [Trello::Error] if the Webhook could not be saved. # # @return [String] the JSON representation of the saved webhook. 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. def update! client.put("/webhooks/#{id}", { description: description, idModel: id_model, callbackURL: callback_url, active: active }) end # Delete this webhook # # @return [String] the JSON response from the Trello API def delete client.delete("/webhooks/#{id}") end # Check if the webhook is activated # # @return [Boolean] def activated? active end end |
Class Method Details
.create(options) ⇒ Trello::Webhook
Create a new webhook and save it to Trello.
41 42 43 44 45 46 |
# File 'lib/trello/webhook.rb', line 41 def create() client.create(:webhook, 'description' => [:description], 'idModel' => [:id_model], 'callbackURL' => [:callback_url]) end |
.find(id, params = {}) ⇒ Trello::Webhook
Find a specific webhook by its ID.
25 26 27 |
# File 'lib/trello/webhook.rb', line 25 def find(id, params = {}) client.find(:webhook, id, params) end |
Instance Method Details
#activated? ⇒ Boolean
Check if the webhook is activated
99 100 101 |
# File 'lib/trello/webhook.rb', line 99 def activated? active end |
#delete ⇒ String
Delete this webhook
92 93 94 |
# File 'lib/trello/webhook.rb', line 92 def delete client.delete("/webhooks/#{id}") end |
#save ⇒ String
Save the webhook.
64 65 66 67 68 69 70 71 72 73 |
# 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! ⇒ String
Update the webhook.
80 81 82 83 84 85 86 87 |
# File 'lib/trello/webhook.rb', line 80 def update! client.put("/webhooks/#{id}", { description: description, idModel: id_model, callbackURL: callback_url, active: active }) end |
#update_fields(fields) ⇒ Trello::Webhook
Returns self.
50 51 52 53 54 55 56 57 |
# 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 |