Class: Twilio::REST::Messaging::V1::WebhookInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/messaging/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



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 154

def initialize(version, payload)
  super(version)

  # Marshaled Properties
  @properties = {
      'account_sid' => payload['account_sid'],
      'service_sid' => payload['service_sid'],
      'webhook_method' => payload['webhook_method'],
      'webhook_filters' => payload['webhook_filters'],
      'pre_webhook_url' => payload['pre_webhook_url'],
      'post_webhook_url' => payload['post_webhook_url'],
      'pre_webhook_retry_count' => payload['pre_webhook_retry_count'].to_i,
      'post_webhook_retry_count' => payload['post_webhook_retry_count'].to_i,
      'target' => payload['target'],
      'url' => payload['url'],
  }

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

Instance Method Details

#account_sidString

Returns The SID of the Account that created the resource.

Returns:

  • (String)

    The SID of the Account that created the resource



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

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:



180
181
182
183
184
185
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 180

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

#fetchWebhookInstance

Fetch a WebhookInstance

Returns:



250
251
252
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 250

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



291
292
293
294
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 291

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

#post_webhook_retry_countString

Returns The number of times to try the post-event webhook request if the first attempt fails.

Returns:

  • (String)

    The number of times to try the post-event webhook request if the first attempt fails



231
232
233
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 231

def post_webhook_retry_count
  @properties['post_webhook_retry_count']
end

#post_webhook_urlString

Returns The absolute URL of the post-event webhook.

Returns:

  • (String)

    The absolute URL of the post-event webhook



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

def post_webhook_url
  @properties['post_webhook_url']
end

#pre_webhook_retry_countString

Returns The number of times to try the pre-event webhook request if the first attempt fails.

Returns:

  • (String)

    The number of times to try the pre-event webhook request if the first attempt fails



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

def pre_webhook_retry_count
  @properties['pre_webhook_retry_count']
end

#pre_webhook_urlString

Returns The absolute URL of the pre-event webhook.

Returns:

  • (String)

    The absolute URL of the pre-event webhook



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

def pre_webhook_url
  @properties['pre_webhook_url']
end

#service_sidString

Returns The SID of the Chat Service that the resource is associated with.

Returns:

  • (String)

    The SID of the Chat Service that the resource is associated with



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

def service_sid
  @properties['service_sid']
end

#targetwebhook.Target

Returns The routing target of the webhook.

Returns:

  • (webhook.Target)

    The routing target of the webhook



237
238
239
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 237

def target
  @properties['target']
end

#to_sObject

Provide a user friendly representation



284
285
286
287
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 284

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

#update(webhook_method: :unset, webhook_filters: :unset, pre_webhook_url: :unset, post_webhook_url: :unset, pre_webhook_retry_count: :unset, post_webhook_retry_count: :unset, target: :unset) ⇒ WebhookInstance

Update the WebhookInstance

Parameters:

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

    The HTTP method to use when sending a webhook request.

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

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

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

    The absolute URL of the pre-event webhook.

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

    The absolute URL of the post-event webhook.

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

    The number of times to try the pre-event webhook request if the first attempt fails. Can be up to 3 and the default is 0.

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

    The number of times to try the post-event webhook request if the first attempt fails. Can be up to 3 and the default is 0.

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

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

Returns:



270
271
272
273
274
275
276
277
278
279
280
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 270

def update(webhook_method: :unset, webhook_filters: :unset, pre_webhook_url: :unset, post_webhook_url: :unset, pre_webhook_retry_count: :unset, post_webhook_retry_count: :unset, target: :unset)
  context.update(
      webhook_method: webhook_method,
      webhook_filters: webhook_filters,
      pre_webhook_url: pre_webhook_url,
      post_webhook_url: post_webhook_url,
      pre_webhook_retry_count: pre_webhook_retry_count,
      post_webhook_retry_count: post_webhook_retry_count,
      target: target,
  )
end

#urlString

Returns The absolute URL of the webhook.

Returns:

  • (String)

    The absolute URL of the webhook



243
244
245
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 243

def url
  @properties['url']
end

#webhook_filtersString

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

Returns:

  • (String)

    The list of webhook event triggers that are enabled for the Service



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

def webhook_filters
  @properties['webhook_filters']
end

#webhook_methodString

Returns The HTTP method to use when sending a webhook request.

Returns:

  • (String)

    The HTTP method to use when sending a webhook request



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

def webhook_method
  @properties['webhook_method']
end