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



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

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 unique id of the Account responsible for this session.

Returns:

  • (String)

    The unique id of the Account responsible for this session.



192
193
194
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 192

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:



183
184
185
186
187
188
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 183

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

#fetchWebhookInstance

Fetch a WebhookInstance

Returns:



253
254
255
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 253

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



297
298
299
300
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 297

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

#post_webhook_retry_countString

Returns The number of retries in case of post-event webhook request failures.

Returns:

  • (String)

    The number of retries in case of post-event webhook request failures.



234
235
236
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 234

def post_webhook_retry_count
  @properties['post_webhook_retry_count']
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.



222
223
224
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 222

def post_webhook_url
  @properties['post_webhook_url']
end

#pre_webhook_retry_countString

Returns The number of retries in case of pre-event webhook request failures.

Returns:

  • (String)

    The number of retries in case of pre-event webhook request failures.



228
229
230
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 228

def pre_webhook_retry_count
  @properties['pre_webhook_retry_count']
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.



216
217
218
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 216

def pre_webhook_url
  @properties['pre_webhook_url']
end

#service_sidString

Returns The unique id of the Chat Service this session belongs to.

Returns:

  • (String)

    The unique id of the Chat Service this session belongs to.



198
199
200
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 198

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.



240
241
242
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 240

def target
  @properties['target']
end

#to_sObject

Provide a user friendly representation



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

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 be used when sending a webhook request.

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

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

  • 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.

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

    The number of retries in case of pre-event webhook request failures. Maximum 3 retries are allowed, the default value is 0.

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

    The number of retries in case of post-event webhook request failures. Maximum 3 retries are allowed, the default value is 0.

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

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

Returns:



276
277
278
279
280
281
282
283
284
285
286
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 276

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 An absolute URL for this webhook.

Returns:

  • (String)

    An absolute URL for this webhook.



246
247
248
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 246

def url
  @properties['url']
end

#webhook_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.



210
211
212
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 210

def webhook_filters
  @properties['webhook_filters']
end

#webhook_methodString

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

Returns:

  • (String)

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



204
205
206
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 204

def webhook_method
  @properties['webhook_method']
end