Class: Telerivet::Webhook

Inherits:
Entity
  • Object
show all
Defined in:
lib/telerivet/webhook.rb

Overview

Represents a webhook that is triggered when specific events occur within a project.

Webhooks allow your server to receive HTTP POST requests when certain events happen, such as when a message’s status changes or when a contact is updated.

When an event occurs that matches a webhook’s event types, Telerivet will send an HTTP POST request to the webhook URL with information about the event. For more information about the webhook request format, see the [Webhook API](/api/webhook) documentation.

Note: The Webhook object is not used for notifying your server when incoming messages are received. To notify a URL when incoming messages are received, you can configure a webhook by [creating a Service](#Project.createService) with type incoming_message_webhook.

Fields:

- id (string, max 34 characters)
    * ID of the webhook
    * Read-only

- url
    * URL that webhook requests are sent to
    * Updatable via API

- secret
    * Secret included with webhook requests for authentication (sent as HTTP basic auth
        password with username 'telerivet')
    * Updatable via API

- events (array of strings)
    * Array of event types that trigger this webhook. Possible values: `send_status`
        (message status updates), `send_broadcast` (broadcast sent), `contact_update` (contact
        added/updated/deleted), `message_metadata` (message  updated)
    * Updatable via API

- project_id
    * ID of the project this webhook belongs to
    * Read-only

Instance Method Summary collapse

Methods inherited from Entity

#get, #initialize, #load, #set, #set_data, #to_s, #vars

Constructor Details

This class inherits a constructor from Telerivet::Entity

Instance Method Details

#deleteObject

Deletes the webhook.



56
57
58
# File 'lib/telerivet/webhook.rb', line 56

def delete()
    @api.do_request("DELETE", get_base_api_path())
end

#eventsObject



80
81
82
# File 'lib/telerivet/webhook.rb', line 80

def events
    get('events')
end

#events=(value) ⇒ Object



84
85
86
# File 'lib/telerivet/webhook.rb', line 84

def events=(value)
    set('events', value)
end

#get_base_api_pathObject



92
93
94
# File 'lib/telerivet/webhook.rb', line 92

def get_base_api_path()
    "/projects/#{get('project_id')}/webhooks/#{get('id')}"
end

#idObject



60
61
62
# File 'lib/telerivet/webhook.rb', line 60

def id
    get('id')
end

#project_idObject



88
89
90
# File 'lib/telerivet/webhook.rb', line 88

def project_id
    get('project_id')
end

#saveObject

Saves any fields that have changed for this webhook.



49
50
51
# File 'lib/telerivet/webhook.rb', line 49

def save()
    super
end

#secretObject



72
73
74
# File 'lib/telerivet/webhook.rb', line 72

def secret
    get('secret')
end

#secret=(value) ⇒ Object



76
77
78
# File 'lib/telerivet/webhook.rb', line 76

def secret=(value)
    set('secret', value)
end

#urlObject



64
65
66
# File 'lib/telerivet/webhook.rb', line 64

def url
    get('url')
end

#url=(value) ⇒ Object



68
69
70
# File 'lib/telerivet/webhook.rb', line 68

def url=(value)
    set('url', value)
end