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

  • account_sid (String)

    The SID of the Account that created this Webhook resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 325

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  || @properties['service_sid']  ,'channel_sid' => channel_sid  || @properties['channel_sid']  ,'sid' => sid  || @properties['sid']  , }
end

Instance Method Details

#account_sidString

Returns:

  • (String)


365
366
367
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 365

def 
    @properties['account_sid']
end

#channel_sidString

Returns:

  • (String)


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

def channel_sid
    @properties['channel_sid']
end

#configurationHash

Returns:

  • (Hash)


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

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:



350
351
352
353
354
355
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 350

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

#date_createdTime

Returns:

  • (Time)


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

def date_created
    @properties['date_created']
end

#date_updatedTime

Returns:

  • (Time)


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

def date_updated
    @properties['date_updated']
end

#deleteBoolean

Delete the WebhookInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



414
415
416
417
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 414

def delete

    context.delete
end

#fetchWebhookInstance

Fetch the WebhookInstance

Returns:



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

def fetch

    context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



464
465
466
467
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 464

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

#service_sidString

Returns:

  • (String)


371
372
373
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 371

def service_sid
    @properties['service_sid']
end

#sidString

Returns:

  • (String)


359
360
361
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 359

def sid
    @properties['sid']
end

#to_sObject

Provide a user friendly representation



457
458
459
460
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 457

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

#typeString

Returns:

  • (String)


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

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)
  • configuration_method (Method) (defaults to: :unset)
  • configuration_filters (Array[String]) (defaults to: :unset)
  • configuration_triggers (Array[String]) (defaults to: :unset)
  • configuration_flow_sid (String) (defaults to: :unset)
  • configuration_retry_count (String) (defaults to: :unset)

Returns:



436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 436

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

#urlString

Returns:

  • (String)


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

def url
    @properties['url']
end