Class: Mandrill::Webhooks

Inherits:
Object
  • Object
show all
Defined in:
lib/mandrill/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(master) ⇒ Webhooks

Returns a new instance of Webhooks.


1694
1695
1696
# File 'lib/mandrill/api.rb', line 1694

def initialize(master)
    @master = master
end

Instance Attribute Details

#masterObject

Returns the value of attribute master


1692
1693
1694
# File 'lib/mandrill/api.rb', line 1692

def master
  @master
end

Instance Method Details

#add(url, description = nil, events = []) ⇒ Hash

Add a new webhook

Parameters:

  • url (String)

    the URL to POST batches of events

  • description (String) (defaults to: nil)

    an optional description of the webhook

  • events (Array) (defaults to: [])

    an optional list of events that will be posted to the webhook

    • String

      events[] the individual event to listen for

Returns:

  • (Hash)

    the information saved about the new webhook

    • Integer

      id a unique integer indentifier for the webhook

    • String

      url The URL that the event data will be posted to

    • String

      description a description of the webhook

    • String

      auth_key the key used to requests for this webhook

    • Array

      events The message events that will be posted to the hook

      - [String] events[] the individual message event (send, hard_bounce, soft_bounce, open, click, spam, unsub, or reject)
      
    • String

      created_at the date and time that the webhook was created as a UTC string in YYYY-MM-DD HH:MM:SS format

    • String

      last_sent_at the date and time that the webhook last successfully received events as a UTC string in YYYY-MM-DD HH:MM:SS format

    • Integer

      batches_sent the number of event batches that have ever been sent to this webhook

    • Integer

      events_sent the total number of events that have ever been sent to this webhook

    • String

      last_error if we've ever gotten an error trying to post to this webhook, the last error that we've seen


1734
1735
1736
1737
# File 'lib/mandrill/api.rb', line 1734

def add(url, description=nil, events=[])
    _params = {:url => url, :description => description, :events => events}
    return @master.call 'webhooks/add', _params
end

#delete(id) ⇒ Hash

Delete an existing webhook

Parameters:

  • id (Integer)

    the unique identifier of a webhook belonging to this account

Returns:

  • (Hash)

    the information for the deleted webhook

    • Integer

      id a unique integer indentifier for the webhook

    • String

      url The URL that the event data will be posted to

    • String

      description a description of the webhook

    • String

      auth_key the key used to requests for this webhook

    • Array

      events The message events that will be posted to the hook

      - [String] events[] the individual message event (send, hard_bounce, soft_bounce, open, click, spam, unsub, or reject)
      
    • String

      created_at the date and time that the webhook was created as a UTC string in YYYY-MM-DD HH:MM:SS format

    • String

      last_sent_at the date and time that the webhook last successfully received events as a UTC string in YYYY-MM-DD HH:MM:SS format

    • Integer

      batches_sent the number of event batches that have ever been sent to this webhook

    • Integer

      events_sent the total number of events that have ever been sent to this webhook

    • String

      last_error if we've ever gotten an error trying to post to this webhook, the last error that we've seen


1795
1796
1797
1798
# File 'lib/mandrill/api.rb', line 1795

def delete(id)
    _params = {:id => id}
    return @master.call 'webhooks/delete', _params
end

#info(id) ⇒ Hash

Given the ID of an existing webhook, return the data about it

Parameters:

  • id (Integer)

    the unique identifier of a webhook belonging to this account

Returns:

  • (Hash)

    the information about the webhook

    • Integer

      id a unique integer indentifier for the webhook

    • String

      url The URL that the event data will be posted to

    • String

      description a description of the webhook

    • String

      auth_key the key used to requests for this webhook

    • Array

      events The message events that will be posted to the hook

      - [String] events[] the individual message event (send, hard_bounce, soft_bounce, open, click, spam, unsub, or reject)
      
    • String

      created_at the date and time that the webhook was created as a UTC string in YYYY-MM-DD HH:MM:SS format

    • String

      last_sent_at the date and time that the webhook last successfully received events as a UTC string in YYYY-MM-DD HH:MM:SS format

    • Integer

      batches_sent the number of event batches that have ever been sent to this webhook

    • Integer

      events_sent the total number of events that have ever been sent to this webhook

    • String

      last_error if we've ever gotten an error trying to post to this webhook, the last error that we've seen


1753
1754
1755
1756
# File 'lib/mandrill/api.rb', line 1753

def info(id)
    _params = {:id => id}
    return @master.call 'webhooks/info', _params
end

#listArray

Get the list of all webhooks defined on the account

Returns:

  • (Array)

    the webhooks associated with the account

    • Hash

      return[] the individual webhook info

      - [Integer] id a unique integer indentifier for the webhook
      - [String] url The URL that the event data will be posted to
      - [String] description a description of the webhook
      - [String] auth_key the key used to requests for this webhook
      - [Array] events The message events that will be posted to the hook
          - [String] events[] the individual message event (send, hard_bounce, soft_bounce, open, click, spam, unsub, or reject)
      - [String] created_at the date and time that the webhook was created as a UTC string in YYYY-MM-DD HH:MM:SS format
      - [String] last_sent_at the date and time that the webhook last successfully received events as a UTC string in YYYY-MM-DD HH:MM:SS format
      - [Integer] batches_sent the number of event batches that have ever been sent to this webhook
      - [Integer] events_sent the total number of events that have ever been sent to this webhook
      - [String] last_error if we've ever gotten an error trying to post to this webhook, the last error that we've seen
      

1712
1713
1714
1715
# File 'lib/mandrill/api.rb', line 1712

def list()
    _params = {}
    return @master.call 'webhooks/list', _params
end

#update(id, url, description = nil, events = []) ⇒ Hash

Update an existing webhook

Parameters:

  • id (Integer)

    the unique identifier of a webhook belonging to this account

  • url (String)

    the URL to POST batches of events

  • description (String) (defaults to: nil)

    an optional description of the webhook

  • events (Array) (defaults to: [])

    an optional list of events that will be posted to the webhook

    • String

      events[] the individual event to listen for

Returns:

  • (Hash)

    the information for the updated webhook

    • Integer

      id a unique integer indentifier for the webhook

    • String

      url The URL that the event data will be posted to

    • String

      description a description of the webhook

    • String

      auth_key the key used to requests for this webhook

    • Array

      events The message events that will be posted to the hook

      - [String] events[] the individual message event (send, hard_bounce, soft_bounce, open, click, spam, unsub, or reject)
      
    • String

      created_at the date and time that the webhook was created as a UTC string in YYYY-MM-DD HH:MM:SS format

    • String

      last_sent_at the date and time that the webhook last successfully received events as a UTC string in YYYY-MM-DD HH:MM:SS format

    • Integer

      batches_sent the number of event batches that have ever been sent to this webhook

    • Integer

      events_sent the total number of events that have ever been sent to this webhook

    • String

      last_error if we've ever gotten an error trying to post to this webhook, the last error that we've seen


1776
1777
1778
1779
# File 'lib/mandrill/api.rb', line 1776

def update(id, url, description=nil, events=[])
    _params = {:id => id, :url => url, :description => description, :events => events}
    return @master.call 'webhooks/update', _params
end