Class: Twilio::REST::IpMessaging::V2::ServiceContext::ChannelContext::WebhookInstance

Inherits:
Twilio::REST::InstanceResource show all
Defined in:
lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, service_sid: nil, channel_sid: nil, sid: nil) ⇒ WebhookInstance

Initialize the WebhookInstance

Parameters:

  • version (Version) —

    Version that contains the resource

  • payload (Hash) —

    payload that contains response from Twilio

  • service_sid (String) (defaults to: nil) —

    The SID of the Service the resource is associated with.

  • channel_sid (String) (defaults to: nil) —

    The SID of the Channel the ChannelWebhook resource belongs to.

  • sid (String) (defaults to: nil) —

    The Twilio-provided string that uniquely identifies the ChannelWebhook resource to fetch.



332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 332

def initialize(version, payload, service_sid: nil, channel_sid: nil, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'account_sid' => payload['account_sid'],
      'service_sid' => payload['service_sid'],
      'channel_sid' => payload['channel_sid'],
      'type' => payload['type'],
      '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 = {
      'service_sid' => service_sid,
      'channel_sid' => channel_sid,
      'sid' => sid || @properties['sid'],
  }
end

Instance Method Details

#account_sid ⇒ String

Returns The SID of the Account that created the resource.

Returns:

  • (String) —

    The SID of the Account that created the resource



381
382
383
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 381

def 
  @properties['account_sid']
end

#channel_sid ⇒ String

Returns The SID of the Channel the ChannelWebhook resource belongs to.

Returns:

  • (String) —

    The SID of the Channel the ChannelWebhook resource belongs to



393
394
395
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 393

def channel_sid
  @properties['channel_sid']
end

#configuration ⇒ Hash

Returns The JSON string that describes the configuration object for the channel webhook.

Returns:

  • (Hash) —

    The JSON string that describes the configuration object for the channel webhook



411
412
413
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 411

def configuration
  @properties['configuration']
end

#context ⇒ WebhookContext

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

Returns:



361
362
363
364
365
366
367
368
369
370
371
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 361

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

#date_created ⇒ Time

Returns The RFC 2822 date and time in GMT when the resource was created.

Returns:

  • (Time) —

    The RFC 2822 date and time in GMT when the resource was created



417
418
419
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 417

def date_created
  @properties['date_created']
end

#date_updated ⇒ Time

Returns The RFC 2822 date and time in GMT when the resource was last updated.

Returns:

  • (Time) —

    The RFC 2822 date and time in GMT when the resource was last updated



423
424
425
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 423

def date_updated
  @properties['date_updated']
end

#delete ⇒ Boolean

Deletes the WebhookInstance

Returns:

  • (Boolean) —

    true if delete succeeds, true otherwise



470
471
472
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 470

def delete
  context.delete
end

#fetch ⇒ WebhookInstance

Fetch a WebhookInstance

Returns:



430
431
432
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 430

def fetch
  context.fetch
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



483
484
485
486
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 483

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

#service_sid ⇒ String

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

Returns:

  • (String) —

    The SID of the Service that the resource is associated with



387
388
389
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 387

def service_sid
  @properties['service_sid']
end

#sid ⇒ String

Returns The unique string that identifies the resource.

Returns:

  • (String) —

    The unique string that identifies the resource



375
376
377
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 375

def sid
  @properties['sid']
end

#to_s ⇒ Object

Provide a user friendly representation



476
477
478
479
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 476

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

#type ⇒ String

Returns The type of webhook.

Returns:

  • (String) —

    The type of webhook



399
400
401
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 399

def type
  @properties['type']
end

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

Update the WebhookInstance

Parameters:

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

    The URL of the webhook to call using the configuration.method.

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

    The HTTP method used to call configuration.url. Can be: GET or POST and the default is POST.

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

    The events that cause us to call the Channel Webhook. Used when type is webhook. This parameter takes only one event. To specify more than one event, repeat this parameter for each event. For the list of possible events, see Webhook Event Triggers.

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

    A string that will cause us to call the webhook when it is found in a message body. This parameter takes only one trigger string. To specify more than one, repeat this parameter for each trigger string up to a total of 5 trigger strings. Used only when type = trigger.

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

    The SID of the Studio Flow to call when an event in configuration.filters occurs. Used only when type = studio.

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

    The number of times to retry the webhook if the first attempt fails. Can be an integer between 0 and 3, inclusive, and the default is 0.

Returns:



456
457
458
459
460
461
462
463
464
465
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 456

def update(configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset, configuration_retry_count: :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,
  )
end

#url ⇒ String

Returns The absolute URL of the resource.

Returns:

  • (String) —

    The absolute URL of the resource



405
406
407
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 405

def url
  @properties['url']
end