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

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/messaging/v1/session/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, session_sid: nil, sid: nil) ⇒ WebhookInstance

Initialize the WebhookInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • session_sid (String) (defaults to: nil)

    The SID of the Session for the webhook.

  • sid (String) (defaults to: nil)

    The SID of the resource to fetch.



301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# File 'lib/twilio-ruby/rest/messaging/v1/session/webhook.rb', line 301

def initialize(version, payload, session_sid: nil, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'account_sid' => payload['account_sid'],
      'session_sid' => payload['session_sid'],
      'target' => payload['target'],
      'url' => payload['url'],
      'configuration' => payload['configuration'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
  }

  # Context
  @instance_context = nil
  @params = {'session_sid' => session_sid, 'sid' => sid || @properties['sid'], }
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



340
341
342
# File 'lib/twilio-ruby/rest/messaging/v1/session/webhook.rb', line 340

def 
  @properties['account_sid']
end

#configurationHash

Returns The configuration of the webhook.

Returns:

  • (Hash)

    The configuration of the webhook



364
365
366
# File 'lib/twilio-ruby/rest/messaging/v1/session/webhook.rb', line 364

def configuration
  @properties['configuration']
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:



325
326
327
328
329
330
# File 'lib/twilio-ruby/rest/messaging/v1/session/webhook.rb', line 325

def context
  unless @instance_context
    @instance_context = WebhookContext.new(@version, @params['session_sid'], @params['sid'], )
  end
  @instance_context
end

#date_createdTime

Returns The ISO 8601 date and time in GMT when the resource was created.

Returns:

  • (Time)

    The ISO 8601 date and time in GMT when the resource was created



370
371
372
# File 'lib/twilio-ruby/rest/messaging/v1/session/webhook.rb', line 370

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The ISO 8601 date and time in GMT when the resource was last updated.

Returns:

  • (Time)

    The ISO 8601 date and time in GMT when the resource was last updated



376
377
378
# File 'lib/twilio-ruby/rest/messaging/v1/session/webhook.rb', line 376

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the WebhookInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



422
423
424
# File 'lib/twilio-ruby/rest/messaging/v1/session/webhook.rb', line 422

def delete
  context.delete
end

#fetchWebhookInstance

Fetch a WebhookInstance

Returns:



383
384
385
# File 'lib/twilio-ruby/rest/messaging/v1/session/webhook.rb', line 383

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



435
436
437
438
# File 'lib/twilio-ruby/rest/messaging/v1/session/webhook.rb', line 435

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

#session_sidString

Returns The SID of the Session for the webhook.

Returns:

  • (String)

    The SID of the Session for the webhook



346
347
348
# File 'lib/twilio-ruby/rest/messaging/v1/session/webhook.rb', line 346

def session_sid
  @properties['session_sid']
end

#sidString

Returns The unique string that identifies the resource.

Returns:

  • (String)

    The unique string that identifies the resource



334
335
336
# File 'lib/twilio-ruby/rest/messaging/v1/session/webhook.rb', line 334

def sid
  @properties['sid']
end

#targetString

Returns The target of the webhook.

Returns:

  • (String)

    The target of the webhook



352
353
354
# File 'lib/twilio-ruby/rest/messaging/v1/session/webhook.rb', line 352

def target
  @properties['target']
end

#to_sObject

Provide a user friendly representation



428
429
430
431
# File 'lib/twilio-ruby/rest/messaging/v1/session/webhook.rb', line 428

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

#update(configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset, configuration_retry_count: :unset, configuration_buffer_messages: :unset, configuration_buffer_window: :unset) ⇒ WebhookInstance

Update the WebhookInstance

Parameters:

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

    The absolute URL the webhook request should be sent to.

  • configuration_method (webhook.Method) (defaults to: :unset)

    The HTTP method we should use when sending a webhook request to url. Can be POST or GET.

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

    The list of events that trigger a webhook event for the Session.

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

    The list of keywords that trigger a webhook event for the Session.

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

    The SID of the studio flow where the webhook should be sent to.

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

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

  • configuration_buffer_messages (Boolean) (defaults to: :unset)

    Whether buffering should be applied to messages. Not set by default.

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

    The period to buffer messages in milliseconds. Default is 3,000 ms.

Returns:



406
407
408
409
410
411
412
413
414
415
416
417
# File 'lib/twilio-ruby/rest/messaging/v1/session/webhook.rb', line 406

def update(configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset, configuration_retry_count: :unset, configuration_buffer_messages: :unset, configuration_buffer_window: :unset)
  context.update(
      configuration_url: configuration_url,
      configuration_method: configuration_method,
      configuration_filters: configuration_filters,
      configuration_triggers: configuration_triggers,
      configuration_flow_sid: configuration_flow_sid,
      configuration_retry_count: configuration_retry_count,
      configuration_buffer_messages: configuration_buffer_messages,
      configuration_buffer_window: configuration_buffer_window,
  )
end

#urlString

Returns The absolute URL of the webhook.

Returns:

  • (String)

    The absolute URL of the webhook



358
359
360
# File 'lib/twilio-ruby/rest/messaging/v1/session/webhook.rb', line 358

def url
  @properties['url']
end