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

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



308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb', line 308

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



348
349
350
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb', line 348

def 
    @properties['account_sid']
end

#channel_sidString



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

def channel_sid
    @properties['channel_sid']
end

#configurationHash



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

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



333
334
335
336
337
338
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb', line 333

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

#date_createdTime



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

def date_created
    @properties['date_created']
end

#date_updatedTime



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

def date_updated
    @properties['date_updated']
end

#deleteBoolean

Delete the WebhookInstance



397
398
399
400
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb', line 397

def delete

    context.delete
end

#fetchWebhookInstance

Fetch the WebhookInstance



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

def fetch

    context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



447
448
449
450
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb', line 447

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

#service_sidString



354
355
356
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb', line 354

def service_sid
    @properties['service_sid']
end

#sidString



342
343
344
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb', line 342

def sid
    @properties['sid']
end

#to_sObject

Provide a user friendly representation



440
441
442
443
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb', line 440

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

#typeString



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

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



419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb', line 419

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



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

def url
    @properties['url']
end