Class: Twilio::REST::Conversations::V1::WebhookInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/conversations/v1/webhook.rb

Overview

PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact [email protected].

Instance Method Summary collapse

Constructor Details

#initialize(version, payload) ⇒ WebhookInstance

Initialize the WebhookInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/twilio-ruby/rest/conversations/v1/webhook.rb', line 151

def initialize(version, payload)
  super(version)

  # Marshaled Properties
  @properties = {
      'account_sid' => payload['account_sid'],
      'method' => payload['method'],
      'filters' => payload['filters'],
      'pre_webhook_url' => payload['pre_webhook_url'],
      'post_webhook_url' => payload['post_webhook_url'],
      'target' => payload['target'],
      'url' => payload['url'],
  }

  # Context
  @instance_context = nil
  @params = {}
end

Instance Method Details

#account_sidString

Returns The unique id of the Account responsible for this conversation.

Returns:

  • (String)

    The unique id of the Account responsible for this conversation.



183
184
185
# File 'lib/twilio-ruby/rest/conversations/v1/webhook.rb', line 183

def 
  @properties['account_sid']
end

#contextWebhookContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



174
175
176
177
178
179
# File 'lib/twilio-ruby/rest/conversations/v1/webhook.rb', line 174

def context
  unless @instance_context
    @instance_context = WebhookContext.new(@version, )
  end
  @instance_context
end

#fetchWebhookInstance

Fetch a WebhookInstance

Returns:



226
227
228
# File 'lib/twilio-ruby/rest/conversations/v1/webhook.rb', line 226

def fetch
  context.fetch
end

#filtersString

Returns The list of webhook event triggers that are enabled for this Service.

Returns:

  • (String)

    The list of webhook event triggers that are enabled for this Service.



195
196
197
# File 'lib/twilio-ruby/rest/conversations/v1/webhook.rb', line 195

def filters
  @properties['filters']
end

#inspectObject

Provide a detailed, user friendly representation



264
265
266
267
# File 'lib/twilio-ruby/rest/conversations/v1/webhook.rb', line 264

def inspect
  values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Conversations.V1.WebhookInstance #{values}>"
end

#methodwebhook.Method

Returns The HTTP method to be used when sending a webhook request.

Returns:

  • (webhook.Method)

    The HTTP method to be used when sending a webhook request.



189
190
191
# File 'lib/twilio-ruby/rest/conversations/v1/webhook.rb', line 189

def method
  @properties['method']
end

#post_webhook_urlString

Returns The absolute url the post-event webhook request should be sent to.

Returns:

  • (String)

    The absolute url the post-event webhook request should be sent to.



207
208
209
# File 'lib/twilio-ruby/rest/conversations/v1/webhook.rb', line 207

def post_webhook_url
  @properties['post_webhook_url']
end

#pre_webhook_urlString

Returns The absolute url the pre-event webhook request should be sent to.

Returns:

  • (String)

    The absolute url the pre-event webhook request should be sent to.



201
202
203
# File 'lib/twilio-ruby/rest/conversations/v1/webhook.rb', line 201

def pre_webhook_url
  @properties['pre_webhook_url']
end

#targetwebhook.Target

Returns The routing target of the webhook.

Returns:

  • (webhook.Target)

    The routing target of the webhook.



213
214
215
# File 'lib/twilio-ruby/rest/conversations/v1/webhook.rb', line 213

def target
  @properties['target']
end

#to_sObject

Provide a user friendly representation



257
258
259
260
# File 'lib/twilio-ruby/rest/conversations/v1/webhook.rb', line 257

def to_s
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Conversations.V1.WebhookInstance #{values}>"
end

#update(method: :unset, filters: :unset, pre_webhook_url: :unset, post_webhook_url: :unset, target: :unset) ⇒ WebhookInstance

Update the WebhookInstance

Parameters:

  • method (String) (defaults to: :unset)

    The HTTP method to be used when sending a webhook request.

  • filters (String) (defaults to: :unset)

    The list of webhook event triggers that are enabled for this Service: ‘onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onConversationUpdated`, `onConversationRemoved`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`

  • pre_webhook_url (String) (defaults to: :unset)

    The absolute url the pre-event webhook request should be sent to.

  • post_webhook_url (String) (defaults to: :unset)

    The absolute url the post-event webhook request should be sent to.

  • target (webhook.Target) (defaults to: :unset)

    The routing target of the webhook. Can be ordinary or route internally to Flex

Returns:



245
246
247
248
249
250
251
252
253
# File 'lib/twilio-ruby/rest/conversations/v1/webhook.rb', line 245

def update(method: :unset, filters: :unset, pre_webhook_url: :unset, post_webhook_url: :unset, target: :unset)
  context.update(
      method: method,
      filters: filters,
      pre_webhook_url: pre_webhook_url,
      post_webhook_url: post_webhook_url,
      target: target,
  )
end

#urlString

Returns An absolute URL for this webhook.

Returns:

  • (String)

    An absolute URL for this webhook.



219
220
221
# File 'lib/twilio-ruby/rest/conversations/v1/webhook.rb', line 219

def url
  @properties['url']
end