Class: Mailgun::Webhook
Overview
Interface to manage webhooks documentation.mailgun.com/api-webhooks.html#webhooks
Instance Attribute Summary collapse
-
#default_webhook_url ⇒ Object
Returns the value of attribute default_webhook_url.
-
#domain ⇒ Object
Returns the value of attribute domain.
Instance Method Summary collapse
-
#available_ids ⇒ Object
List of currently available webhooks.
-
#create(id, url = default_webhook_url) ⇒ Object
Creates a new webhook Note: Creating an Open or Click webhook will enable Open or Click tracking.
-
#delete(id) ⇒ Object
Deletes an existing webhook Note: Deleting an Open or Click webhook will disable Open or Click tracking.
-
#find(id) ⇒ Object
Returns details about the webhook specified.
-
#initialize(mailgun, domain, url) ⇒ Webhook
constructor
Used internally, called from Mailgun::Base.
-
#list ⇒ Object
Returns a list of webhooks set for the specified domain.
-
#update(id, url = default_webhook_url) ⇒ Object
Updates an existing webhook.
Constructor Details
#initialize(mailgun, domain, url) ⇒ Webhook
Used internally, called from Mailgun::Base
8 9 10 11 12 |
# File 'lib/mailgun/webhook.rb', line 8 def initialize(mailgun, domain, url) @mailgun = mailgun @domain = domain @default_webhook_url = url end |
Instance Attribute Details
#default_webhook_url ⇒ Object
Returns the value of attribute default_webhook_url.
5 6 7 |
# File 'lib/mailgun/webhook.rb', line 5 def default_webhook_url @default_webhook_url end |
#domain ⇒ Object
Returns the value of attribute domain.
5 6 7 |
# File 'lib/mailgun/webhook.rb', line 5 def domain @domain end |
Instance Method Details
#available_ids ⇒ Object
List of currently available webhooks
15 16 17 |
# File 'lib/mailgun/webhook.rb', line 15 def available_ids %w(bounce deliver drop spam unsubscribe click open).map(&:to_sym) end |
#create(id, url = default_webhook_url) ⇒ Object
Creates a new webhook Note: Creating an Open or Click webhook will enable Open or Click tracking
31 32 33 34 |
# File 'lib/mailgun/webhook.rb', line 31 def create(id, url=default_webhook_url) params = {:id => id, :url => url} Mailgun.submit :post, webhook_url, params end |
#delete(id) ⇒ Object
Deletes an existing webhook Note: Deleting an Open or Click webhook will disable Open or Click tracking
44 45 46 |
# File 'lib/mailgun/webhook.rb', line 44 def delete(id) Mailgun.submit :delete, webhook_url(id) end |
#find(id) ⇒ Object
Returns details about the webhook specified
25 26 27 |
# File 'lib/mailgun/webhook.rb', line 25 def find(id) Mailgun.submit :get, webhook_url(id) end |