Class: Twilio::REST::Conversations::V1::ServiceContext::ConfigurationContext::WebhookInstance

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, chat_service_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) —

    The SID of the Call resource to fetch.



286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 286

def initialize(version, payload , chat_service_sid: nil)
    super(version)
    
    
    # Marshaled Properties
    @properties = { 
        'account_sid' => payload['account_sid'],
        'chat_service_sid' => payload['chat_service_sid'],
        'pre_webhook_url' => payload['pre_webhook_url'],
        'post_webhook_url' => payload['post_webhook_url'],
        'filters' => payload['filters'],
        'method' => payload['method'],
        'url' => payload['url'],
    }

    # Context
    @instance_context = nil
    @params = { 'chat_service_sid' => chat_service_sid  || @properties['chat_service_sid']  , }
end

Instance Method Details

#account_sid ⇒ String

Returns The unique ID of the Account responsible for this service.

Returns:

  • (String) —

    The unique ID of the Account responsible for this service.



319
320
321
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 319

def 
    @properties['account_sid']
end

#chat_service_sid ⇒ String

Returns The unique ID of the Conversation Service this conversation belongs to.

Returns:



325
326
327
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 325

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



310
311
312
313
314
315
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 310

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

#fetch ⇒ WebhookInstance

Fetch the WebhookInstance

Returns:



362
363
364
365
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 362

def fetch

    context.fetch
end

#filters ⇒ Array<String>

Returns The list of events that your configured webhook targets will receive. Events not configured here will not fire. Possible values are onParticipantAdd, onParticipantAdded, onDeliveryUpdated, onConversationUpdated, onConversationRemove, onParticipantRemove, onConversationUpdate, onMessageAdd, onMessageRemoved, onParticipantUpdated, onConversationAdded, onMessageAdded, onConversationAdd, onConversationRemoved, onParticipantUpdate, onMessageRemove, onMessageUpdated, onParticipantRemoved, onMessageUpdate or onConversationStateUpdated.

Returns:

  • (Array<String>) —

    The list of events that your configured webhook targets will receive. Events not configured here will not fire. Possible values are onParticipantAdd, onParticipantAdded, onDeliveryUpdated, onConversationUpdated, onConversationRemove, onParticipantRemove, onConversationUpdate, onMessageAdd, onMessageRemoved, onParticipantUpdated, onConversationAdded, onMessageAdded, onConversationAdd, onConversationRemoved, onParticipantUpdate, onMessageRemove, onMessageUpdated, onParticipantRemoved, onMessageUpdate or onConversationStateUpdated.



343
344
345
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 343

def filters
    @properties['filters']
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



398
399
400
401
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 398

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

#method ⇒ Method

Returns:

  • (Method)


349
350
351
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 349

def method
    @properties['method']
end

#post_webhook_url ⇒ String

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.



337
338
339
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 337

def post_webhook_url
    @properties['post_webhook_url']
end

#pre_webhook_url ⇒ String

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.



331
332
333
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 331

def pre_webhook_url
    @properties['pre_webhook_url']
end

#to_s ⇒ Object

Provide a user friendly representation



391
392
393
394
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 391

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

#update(pre_webhook_url: :unset, post_webhook_url: :unset, filters: :unset, method: :unset) ⇒ WebhookInstance

Update the WebhookInstance

Parameters:

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

  • filters (Array[String]) (defaults to: :unset) —

    The list of events that your configured webhook targets will receive. Events not configured here will not fire. Possible values are onParticipantAdd, onParticipantAdded, onDeliveryUpdated, onConversationUpdated, onConversationRemove, onParticipantRemove, onConversationUpdate, onMessageAdd, onMessageRemoved, onParticipantUpdated, onConversationAdded, onMessageAdded, onConversationAdd, onConversationRemoved, onParticipantUpdate, onMessageRemove, onMessageUpdated, onParticipantRemoved, onMessageUpdate or onConversationStateUpdated.

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

    The HTTP method to be used when sending a webhook request. One of GET or POST.

Returns:



374
375
376
377
378
379
380
381
382
383
384
385
386
387
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 374

def update(
  pre_webhook_url: :unset, 
  post_webhook_url: :unset, 
  filters: :unset, 
  method: :unset
)

    context.update(
        pre_webhook_url: pre_webhook_url, 
        post_webhook_url: post_webhook_url, 
        filters: filters, 
        method: method, 
    )
end

#url ⇒ String

Returns An absolute API resource URL for this webhook.

Returns:

  • (String) —

    An absolute API resource URL for this webhook.



355
356
357
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 355

def url
    @properties['url']
end