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

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, chat_service_sid: nil, conversation_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.



296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb', line 296

def initialize(version, payload , chat_service_sid: nil, conversation_sid: nil, sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'sid' => payload['sid'],
        'account_sid' => payload['account_sid'],
        'chat_service_sid' => payload['chat_service_sid'],
        'conversation_sid' => payload['conversation_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 = { 'chat_service_sid' => chat_service_sid  || @properties['chat_service_sid']  ,'conversation_sid' => conversation_sid  || @properties['conversation_sid']  ,'sid' => sid  || @properties['sid']  , }
end

Instance Method Details

#account_sidString

Returns The unique ID of the [Account](www.twilio.com/docs/iam/api/account) responsible for this conversation.

Returns:



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

def 
    @properties['account_sid']
end

#chat_service_sidString

Returns The SID of the [Conversation Service](www.twilio.com/docs/conversations/api/service-resource) the Participant resource is associated with.

Returns:



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

def chat_service_sid
    @properties['chat_service_sid']
end

#configurationHash

Returns The configuration of this webhook. Is defined based on target.

Returns:

  • (Hash)

    The configuration of this webhook. Is defined based on target.



366
367
368
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb', line 366

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:



321
322
323
324
325
326
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb', line 321

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

#conversation_sidString

Returns The unique ID of the [Conversation](www.twilio.com/docs/conversations/api/conversation-resource) for this webhook.

Returns:



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

def conversation_sid
    @properties['conversation_sid']
end

#date_createdTime

Returns The date that this resource was created.

Returns:

  • (Time)

    The date that this resource was created.



372
373
374
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb', line 372

def date_created
    @properties['date_created']
end

#date_updatedTime

Returns The date that this resource was last updated.

Returns:

  • (Time)

    The date that this resource was last updated.



378
379
380
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb', line 378

def date_updated
    @properties['date_updated']
end

#deleteBoolean

Delete the WebhookInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



385
386
387
388
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb', line 385

def delete

    context.delete
end

#fetchWebhookInstance

Fetch the WebhookInstance

Returns:



393
394
395
396
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb', line 393

def fetch

    context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



432
433
434
435
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb', line 432

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

#sidString

Returns A 34 character string that uniquely identifies this resource.

Returns:

  • (String)

    A 34 character string that uniquely identifies this resource.



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

def sid
    @properties['sid']
end

#targetString

Returns The target of this webhook: ‘webhook`, `studio`, `trigger`.

Returns:

  • (String)

    The target of this webhook: ‘webhook`, `studio`, `trigger`



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

def target
    @properties['target']
end

#to_sObject

Provide a user friendly representation



425
426
427
428
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb', line 425

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

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

Update the WebhookInstance

Parameters:

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

    The absolute url the webhook request should be sent to.

  • configuration_method (Method) (defaults to: :unset)
  • configuration_filters (Array[String]) (defaults to: :unset)

    The list of events, firing webhook event for this Conversation.

  • configuration_triggers (Array[String]) (defaults to: :unset)

    The list of keywords, firing webhook event for this Conversation.

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

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

Returns:



406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb', line 406

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

#urlString

Returns An absolute API resource URL for this webhook.

Returns:

  • (String)

    An absolute API resource URL for this webhook.



360
361
362
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb', line 360

def url
    @properties['url']
end